随笔分类 - java
摘要:public class Sample { public static void main(String[] args) { int num1 = 10, num2 = 20; int num3 = 5, num4 = 7; System.out.println(num1++); System.out.println(...
阅读全文
摘要:public class Sample { public static void main(String[] args) { String str = "Hello world"; System.out.println("String is: " + str); String str2 = new String("Welcome to java"); System.out.println("The
阅读全文
摘要:public class Sample { public static void main(String[] args) { int num; num = 5; System.out.println("the value of num is " + num); } } OUTPUT: the value of num...
阅读全文
摘要:public class Sample { public static void main(String[] args) { // java compiler ignores the comment System.out.println("Java programmer"); /* * comments make c...
阅读全文
摘要:public class Sample { public static void main(String[] args) { System.out.print("Hello programmers!!!"); } } OUTPUT: Hello programmers!!!
阅读全文
摘要:public class Sample { public static void main(String[] args) {int a, b, c, d, e; Scanner s = new Scanner(System.in); System.out.print("Enter any integer a:"); a = s.nex...
阅读全文
摘要:public class Solution { public static void main(String[] args) { int dNum = 1264; String str = ""; while (dNum > 0) { int rem = dNum % 2; str = rem + str; dNum = dNum / 2; } System.out.println("Binary
阅读全文
摘要:package testpacknm; import java.util.Scanner; public class testcnm { public static void main(String[] args) { int dNum = 5; System.out.println("Binary is: " + Integer.toBinaryString(dNum)); } }
阅读全文
摘要:public class Solution { public static void main(String[] args) { Scanner ip = new Scanner(System.in); System.out.print("Enter radius: "); double radius = ip.nextDouble(); double circumference = 2 * 3.
阅读全文
摘要:public class Solution { public static void main(String[] args) { Scanner ip = new Scanner(System.in); System.out.print("Enter a number: "); double n = ip.nextDouble(); ...
阅读全文
摘要:public class Solution { public static void main(String[] args) { Scanner ip = new Scanner(System.in); double input = 0; int count = 0; double sum = 0; while (input != -1) { System.out.print("Enter inp
阅读全文
摘要:public class Solution { public static void main(String[] args) { Scanner ip = new Scanner(System.in); System.out.print("Enter A: "); int a = ip.nextInt(); System.out.print("Enter B: "); int b = ip.nex
阅读全文
摘要:public class Solution { public static void main(String[] args) { int x = 11, y = 7; int res = 1; for (int i = 1; i <= y; i++) res = i * x; System.out.println("The product of " + x + " and " + y + " is
阅读全文
摘要:输出
阅读全文
摘要:package testjavapro; import org.junit.*; import org.junit.Test; import static org.junit.Assert.assertEquals; public class testjava { @BeforeClass public static void beforeClass() { ...
阅读全文
摘要:public class Animal { private String name; private int id; public Animal(String myName, int myid) { name = myName; id = myid; } public void eat(){ System.out.println(name+"正在吃"); } public void sleep()
阅读全文