1. 程式人生 > >自學Java測試代碼

自學Java測試代碼

wan 二維數組 ted eth args bin -- pac blog

2017-08-22 21:23:37、

writer:pprp

package test;

public class helloWorld {
     int maxn = 123;
     //常量,需要定義一個對象調用
     final int MAX = 20;
     //類常量,不需要再定義一個對象來調用
     static final int MIN = -100;
     
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        helloWorld p = new
helloWorld(); int maxm = 123; char a = ‘好‘; char b = ‘不‘; char c = ‘好‘; int a1 = 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); //無符號右移 System.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}; //增強版for循環 for(int mm : arr) { System.out.println(mm); } for(int i = 0 ; i < s.length ; i++) System.out.println(s[i]); for(int i : nums) System.out.println(i); //一維數組的使用 int [] ans = {3,2,4,3,22,34}; for(int i = 0 ; i < ans.length; i++) System.out.println(ans[i]); //二維數組的使用 int binary_arr[][] = new int[4][4]; for(int i = 0 ; i < 4 ; i++) { binary_arr[i] = new int[4]; } System.out.println("------"); for(int i = 0 ; i < 4 ; i++) for(int j = 0; j < 4 ; j++) { binary_arr[i][j] = i * j; } for(int j = 0 ; j < 4 ; j++) for(int i = 0 ; i < 4; i++) { System.out.println(binary_arr[i][j]); } } void printnumber() { int c = 20; short y; int z; long k; char d; } }

自學Java測試代碼