zoukankan      html  css  js  c++  java
  • 自学Java测试代码一数据类型、数组使用

    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;
        }
    
    }
  • 相关阅读:
    QML的一些基础的区分
    qml的一个文章----可以看出状态、动画的使用
    凡是人性的,都是如下的
    全国经纬度,具体到县
    web-nodkit 入门
    一个文章-转年收入50万美元的软件工程师做的是什么类型的工作
    qml 封装技巧-利用数据来进行适配
    windbg内核诊断方式--转载
    Windbg程序调试--转载
    编写你自己的单点登录(SSO)服务
  • 原文地址:https://www.cnblogs.com/pprp/p/7413754.html
Copyright © 2011-2022 走看看