Home >Java >javaTutorial >What is the assignment method of java long type data?
When a large value appears in the program (exceeding the int type: -2^31 to 2^31 - 1), The type needs to be changed to Long type.
long l = 1507772738542; Long l1 = (long)1507772738542;
The above writing method will report an error during compilation.
It probably means that the data is too long and exceeds the value of type int.
Long l = 1507772738542L;
You can add L or l after the data.
I get a Long type data from an object and assign it to a long variable:
long startsecond = tracelist.get(i).getTracesecond();
Because Tracesecond must have a value when acquiring data before, so the null data was not judged. However, later it was found that the attribute of data was null. When executing the code, the code will get stuck in this place and will never be executed. Go down.
Writing a test example alone, I found that a null pointer exception was reported. I don’t know if it was caused by my code in the thread.
The above is the detailed content of What is the assignment method of java long type data?. For more information, please follow other related articles on the PHP Chinese website!