方法介绍:
有时候我们需要获取某一变量的类型时有哪些方法?
使用反射的方法: 变量名.getClass().getSimpleName() 来判断。
使用 instanceof 来判断:变量名 instanceof 类型来判断。
图片详解:
1.使用反射的方法来判断
2.使用 instanceof 来判断
方法介绍:
有时候我们需要获取某一变量的类型时有哪些方法?
使用反射的方法: 变量名.getClass().getSimpleName() 来判断。
使用 instanceof 来判断:变量名 instanceof 类型来判断。
图片详解:
1.使用反射的方法来判断
2.使用 instanceof 来判断