hi,
why explicit cast is *not* required here? static Float f3 = new Float(5.5); //causes compile-time error b'se, by default floating-point literal type is double
but requires here,
//static Short sh1 = new Short((short)12);
static Short sh1 = new Short(12); //causes compile-time error b'se, by default integer literal type is int
//static Byte bt = new Byte((byte)10);
static Byte bt = new Byte(10); //causes compile-time error b'se, by default integer literal type is int
in case of
long var1 = 12l;
float var2 = 3.2f
I call characters at end of literal 'l' and 'f' as literal-type specifier(correct me if im wrong)
Why there is run-time exception here? static Long l3 = new Long("20l"); // causes run-time exception - java.lang.NumberFormatException
which is not here,
static Float f2 = new Float("5.5f");
static Double d2 = new Double("4.2d");
Can someone explain why there is such behaviour in constructor?
Am I asking silly question? I dont know, but i want to know WHY.
thanks in advance,
katharnakh.