0
点赞
收藏
分享

微信扫一扫

JAVA系统学习

吓死我了_1799 2022-01-20 阅读 128
package cn.itcast.day01;

public class HelloWorld {
    static String s1 = "hello";
    public static void main(String[] args){
        String s2 = "world";
        System.out.println(s1);
        System.out.println(s2);
    }
}

数据类型:

package cn.itcast.day01;

public class Demo0Method{
    static final double PI = 3.14;
    static  int age = 25;
    public static void main(String[] args){
        one();
        two();
        three();
        four();
        five();
    }
    public static void one(){
        for(int i = 0;i < 5; i++){
            for (int j = 0; j < 4; j++) {
            System.out.println('*');
            }
            }
        }
    public static void two(){
        byte a = 64;
        short b = 32564;
        int c = 23;
        long d = 235682441;
        long e = a + b + c + d;
        float f = 15.26f;
        double g = 14452.12d;
        double h = f + g;
        System.out.println(h);
        System.out.println("结果是:" + e);
    }
    public static void three(){
        final int number;
        char word = 'j',word2 = 'k';
        int p = 12456,g = 2545;
        char c1 = '\\';
        char c2 = '\u4545';
        number = 154578;
        System.out.println("Word对应的位置是:" + (int)word);
        System.out.println("word2对应的位置是:" + (int)word2);
        System.out.println("p和g对应的Unicode是:" + (char)p + (char)g);
        System.out.println(c1);
        System.out.println(c2);
        System.out.println(number);
        System.out.println(PI);
    }
    public static void four(){
        int a = 12;
        int b = 25;
        int c = a + b;
        System.out.println(c);
        System.out.println("和为:" + (a + b));
        System.out.println("商为:" + (a / b));
        System.out.println(a > b);
        System.out.println(a != b);
        boolean res = (a < b)&&(a != b);
        boolean res1 = (a < b )||(a == b);
        System.out.println(res);
        System.out.println(res1);
        boolean d = 20 < 12? true:false;
        System.out.println(d);
    }
    public static void five(){
        byte mybyte = 127;
        int myint = 12;
        float myfloat = 12.45f;
        double mydouble = 153.254;
        char mychar = 12;
        System.out.println("byte和float的运算结果:" +(mybyte + myfloat));
    }
}


举报

相关推荐

0 条评论