我有一个关于在 java 中从 int 转换为 long 的问题。为什么浮动没有问题:
float f = (float)45.45;//compiles no issue.
float f = 45.45f; //compiles no issue.
但是对于长类型,这似乎是一个问题:
long l = (long)12213213213;
//with L or l at the end it will work though.
long l = (long)12213213213L;
似乎一旦编译器由于超出范围的问题而通知错误,它就会阻塞在那里,而不检查程序员可能计划的任何可能的转换。
你怎么看?为什么会这样,有什么特别的原因?
提前致谢。