scarcoco / projx

5 stars 0 forks source link

01. 基本语法 #1

Open scarcoco opened 5 years ago

scarcoco commented 5 years ago

基本语法

xxx

image

主函数

import basic.syntax.PrimitiveType;

public class Main {
    public static void main(String[] args) {
        PrimitiveType pt = new PrimitiveType();
        pt.println();
    }
}

类型

基本类型

基本类型包括8中基本类型,其中6中数字和字符、布尔值。

// basic.syntax.PrimitiveType
package basic.syntax;

public class PrimitiveType {
    public PrimitiveType() {}

    public void println() {
        System.out.println("package: java.lang.Byte");
        System.out.println("Byte.SIZE = " + Byte.SIZE);
        System.out.println("Byte.MIN_VALUE = " + Byte.MIN_VALUE);
        System.out.println("Byte.MAX_VALUE = " + Byte.MAX_VALUE);

        System.out.println("\npackage: java.lang.Short");
        System.out.println("Short.SIZE = " + Short.SIZE);
        System.out.println("Short.MIN_VALUE = " + Short.MIN_VALUE);
        System.out.println("Short.MAX_VALUE = " + Short.MAX_VALUE);

        System.out.println("\npackage: java.lang.Integer");
        System.out.println("Integer.SIZE = " + Integer.SIZE);
        System.out.println("Integer.MIN_VALUE = " + Integer.MIN_VALUE);
        System.out.println("Integer.MAX_VALUE = " + Integer.MAX_VALUE);

        System.out.println("\npackage: java.lang.Long");
        System.out.println("Long.SIZE = " + Long.SIZE);
        System.out.println("Long.MIN_VALUE = " + (int) Long.MIN_VALUE);
        System.out.println("Long.MAX_VALUE = " + (int) Long.MAX_VALUE);

        System.out.println("\npackage: java.lang.Float");
        System.out.println("Float.SIZE = " + Float.SIZE);
        System.out.println("Float.MIN_VALUE = " + Float.MIN_VALUE);
        System.out.println("Float.MAX_VALUE = " + Float.MAX_VALUE);

        System.out.println("\npackage: java.lang.Double");
        System.out.println("Double.SIZE = " + Double.SIZE);
        System.out.println("Double.MIN_VALUE = " + Double.MIN_VALUE);
        System.out.println("Double.MAX_VALUE = " + Double.MAX_VALUE);

        System.out.println("\npackage: java.lang.Character");
        System.out.println("Character.SIZE = " + Character.SIZE);
        System.out.println("Character.MIN_VALUE = " + (int) Character.MIN_VALUE);
        System.out.println("Character.MAX_VALUE = " + (int) Character.MAX_VALUE);

        System.out.println("\npackage: java.lang.Boolean");
        System.out.println("Boolean.FALSE = " + Boolean.FALSE);
        System.out.println("Boolean.TRUE = " + Boolean.TRUE);

    }
}