yulin3192 发表于 2018-5-5 16:16:23




public class MainClass{
        public static void main(String args[]){
                char ch1 = 'w',ch2 = '好';
                int p1 = 32831,p2 = 30452;
                /**数据类型转换由低到高**/
                float x = 100;
                int z = 50;
                float y = z;
                /**数据转换由高到低**/
                int a = (int)34.89;
                long b = (long)56.98F;
                int c = (int)1999L;
                int d = 128;
                long e = 77777;
                float f = 2e3f;
                double g = 3.14e-300;
                double result = f * g;
                System.out.println("f = " + f);
                System.out.println("g = " + g);
                System.out.println("result = " + result);
                g = 1234.123456789;
                c = (int)d;
                f = (float)g;
                System.out.println("d = " + c);
                System.out.println("e = " + e);
                System.out.println("f = " + f);
                System.out.println("g = " + g);
                System.out.println(ch1 + "的位置:" + (int)ch1);
                System.out.println("\"" +ch2 +"\"的位置:" + (int)ch2);
                System.out.println("第" + p1 + "个位置上的字符是:" + (char)p1);
                System.out.println("第" + p2 + "个位置上的字符是: " + (char)p2);
                System.out.println(y);
                System.out.println(x);
                System.out.println(a);
                System.out.println(b);
                System.out.println(c);
        }
}
F:\abc>java MainClass
f = 2000.0
g = 3.14E-300
result = 6.28E-297
d = 128
e = 77777
f = 1234.1234
g = 1234.123456789
w的位置:119
"好"的位置:22909
第32831个位置上的字符是:耿
第30452个位置上的字符是: 直
50.0
100.0
34
56
128

南城以南冬未央 发表于 2018-6-26 22:40:00

学到了学到了

对长亭晚 发表于 2019-9-17 09:14:02

补码我记得好像是源码的反码加一,而不是单纯的0变1,1变0?

落单riki君 发表于 2020-11-9 21:54:14

对长亭晚 发表于 2019-9-17 09:14
补码我记得好像是源码的反码加一,而不是单纯的0变1,1变0?

原文是用7的补码来找-8的补码,所以等于已经加一了{:10_281:}

连帅帅 发表于 2021-1-6 17:59:16

abstract抽象类         assert        boolean基本数据类型 boolean类型        break中断循环关键字        byte 基本数据类型 byte
case结合switch用,组成switch case块        catch结合try用,组成try catch块,捕获异常        char 基本数据类型 char字符型        class类关键字        const
continue用于跳出本次循环        default默认关键字,jdk8里面用于定义抽象类中默认方法        do结合while用,组成 do while 语句        double 基本数据类型 浮点数        else结合if使用,组成if else 语句
enum枚举类        extends继承关键字        final最终不可变得关键字,可修饰类属性方法等        finally集合try catch finally使用,里面常写一定会执行的代码块        float 基本数据类型 float
forfor循环        goto        if结合else组成if else语句,用于判断        implements实现类的继承关键字        import 导包关键字
instanceof用于判断是都是本类类型        int基本数据类型 int 整型        interface 接口关键字        long 基本数据类型 long        native 类修饰关键字
newnew对象        package包关键字        private权限修饰符 表私有        protected 权限修饰符 被保护的        public 修饰符权限 public最常用的
return返回关键字        short 基本数据类型 short 短整型        static 静态属性修饰关键字        strictfp        super 引用父类的关键字
switch集合case用,组成switch case块        synchronized同步关键字        this 对象调用this关键字,表示调用者        throw抛出异常,用在代码块中        throws 抛出异常,用在类后面,表示可能会出现的异常类型
transient        try 结合catch用,组成捕获异常的try catch 块        void返回值空关键字        volatile类修饰符关键字        whilewhile(条件)表循环的关键字

误入码农门 发表于 2021-6-15 16:01:54

先赞后看
页: 1 [2]
查看完整版本: 【Java 教程(原创)】006.标识符和关键字以及基本数据类型