码迷,mamicode.com
首页 > 编程语言 > 详细

自学Java测试代码

时间:2017-08-22 23:21:00      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:需要   writer   public   rgs   lis   char   package   logs   ber   

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测试代码

标签:需要   writer   public   rgs   lis   char   package   logs   ber   

原文地址:http://www.cnblogs.com/pprp/p/7413754.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!