Java不接受价值 [英] Java is not accepting value
本文介绍了Java不接受价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个代码,我在其中尝试在long变量中赋值。
但是java编译器显示的错误是整数过大。
I我试图以长型存储600851475143。
:::代码:::
等级总和
{
static public void main(String args [])
{
long num = 600851475143;
}
}
请帮助..... :(
解决方案
< blockquote>对于 long
值的显式设置,你应该附加一个''L',否则编译器将把它作为 int
它会溢出:
long num = 600851475143L;
你好
你需要在数字的末尾添加一个L.
class 总和
{
static public void main(字符串 args [])
{
long num = 600851475143L;
}
}
Valery。
>
I am writing a code in which I am trying to assign a value in long variable.
But java compiler is showing error that too large integer number.
I am trying to store 600851475143 in long type still.
:::code:::
class Sum
{
static public void main(String args[])
{
long num=600851475143;
}
}
Please help..... :(
解决方案
For explicit setting oflong
values you should append a ''L'' otherwise the compiler will take it as anint
and it will overflow:
long num=600851475143L;
Hello
you need to add an L at the end of the number.
class Sum { static public void main(String args[]) { long num=600851475143L; } }
Valery.
这篇关于Java不接受价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文