2017-08-22 21:23:37,
Writer:pprp
Packagetest; Public classHelloWorld {intMAXN = 123; //constants, you need to define an object call Final intMAX = 20; //class constant, you do not need to define an object to invoke the Static Final intMIN =-100; Public Static voidMain (string[] args) {//TODO auto-generated Method StubHelloWorld p =NewHelloWorld (); intMAXM = 123; CharA = ' good '; Charb = ' No '; Charc = ' good '; intA1 = 0, a2 = -1000, a3 = 2; System.out.println ("HelloWorld"); System.out.println ("Haobuhaoma~:" +a+b+c); System.out.println ("MAXM:" +MAXM); System.out.println ("MAXN:" +P.MAXN); System.out.println (P.max); System.out.println (MIN); System.out.println (! (A1 >A2)); SYSTEM.OUT.PRINTLN (A3<< 3); //Unsigned Right ShiftSYSTEM.OUT.PRINTLN (A2 >>> 3); SYSTEM.OUT.PRINTLN (A2>> 3); String s[]= {"Zhangsan", "Wangwu", "Lisi"}; int[]nums = {0,1,2,3,4,5,6,7,8,9}; int[] arr = {1,2,3,4,5}; //Enhanced for Loop for(intMm:arr) {System.out.println (mm); } for(inti = 0; i < s.length; i++) System.out.println (S[i]); for(inti:nums) System.out.println (i); //use of one-dimensional arrays int[] ans = {3,2,4,3,22,34}; for(inti = 0; i < ans.length; i++) System.out.println (Ans[i]); //use of two-dimensional arrays intBinary_arr[][] =New int[4] [4]; for(inti = 0; I < 4; i++) {Binary_arr[i]=New int[4]; } System.out.println ("------"); for(inti = 0; I < 4; i++) for(intj = 0; J < 4; J + +) {Binary_arr[i][j]= i *J; } for(intj = 0; J < 4; J + +) for(inti = 0; I < 4; i++) {System.out.println (binary_arr[i][j]); } } voidPrintnumber () {intc = 20; Shorty; intZ; LongK; CharD; }}
Self-study Java test code