javaserializationdeserializationexternalizable

Conversion form int to long


I have created a class called Employee and I have an ArrayList for storing all the contact numbers of the employee. I have defined a method called addcontact() to add numbers to the list. If I use an int then it says that the number is out of range, so I changed it to long, but still I get the same error.

I am using Externalizable to serialize and deserialize the Employee details.

enter image description here

enter image description here


Solution

  • You should add L at the end of that number (eg. 1234567890123L). Otherwise, it's considered an int constant, and therefore out of range.