前几天我注意到我可以调用 boolean.class,但不能调用 integer.class(或其他基元)。是什么让布尔值如此特别?
注意:我说的是 boolean.class,而不是 Boolean.class(这是有道理的)。
呃:我尝试了integer.class,而不是int.class。我不觉得自己很笨吗:\
Not integer.class
but int.class
。是的你可以。 JRE 6:
public class TestTypeDotClass{
public static void main(String[] args) {
System.out.println(boolean.class.getCanonicalName());
System.out.println(int.class.getCanonicalName());
System.out.println(float.class.getCanonicalName());
System.out.println(Boolean.class.getCanonicalName());
}
}
outputs
boolean
int
float
java.lang.Boolean
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)