Java instantiate Short object in 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?
为什么我们需要用字符串或短字符串来获取构造函数。