我想知道为什么我们可以这样做:的Java实例Short对象在Java中
Long l = 2L;
Float f = 2f;
Double d = 2d;
甚至
Double d = new Double(2);
,而不是
Short s = 2s; //or whatever letter it could be
也不
Short s = new Short(2); //I know in this case 2 is an int but couldn't it be casted internally or something?
为什么我们需要使用String或Short来构造函数。
没有短也不字节文字中Java的。 – 2012-07-17 16:06:36
@ Eng.Fouad是正确的。 0xFF是java中的一个int,“>>和<<运算符取和返回整数,短和字节只剩下一点。不知道为什么。 – lynks 2012-07-17 16:08:19