代码1

/**
 * @authar HanSin
 * @date 2021/4/16 8:13
 */
public class erro {
    public static void main(String[] args) {
        float f = 1.1f; //1.1在编译中默认是double类型,赋值给float需要转换,由于使用频率高,只需在数字后边+f即可
        byte a=0,b=3;
        byte c=(byte) (a+b); //(a+b)默认是int
        short s=23;s+=12; //s+=12 short+=12
        short s1 =23;
        //s1=s1+12; //报错的int+short



        System.out.println(Byte.MAX_VALUE); //8位 7位 2^7-1=127
        System.out.println(Byte.MIN_VALUE); // -2^7=-128

        System.out.println(Integer.MAX_VALUE); //2147483647 2^31-1
        System.out.println(Integer.MIN_VALUE); //-2147483648

        System.out.println(""+'a'+1); //字符串+任何其他内容 结果都是字符串
        System.out.println('a'+1); //单个的字符本质是 数字 和ASCII码

        int[] array = {'a','b',1,2}; //单个的字符本质是 数字 和ASCII码
        for (int i = 0;i

你可能感兴趣的:(代码1)