0

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

Eran
  • 387,369
  • 54
  • 702
  • 768

3 Answers3

3

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

Eran
  • 387,369
  • 54
  • 702
  • 768
2

Values of type long should have an L at the end: 9929929939L.

RealSkeptic
  • 33,993
  • 7
  • 53
  • 79
1

Int
Minimum value is - 2,147,483,648.(-2^31)
Maximum value is 2,147,483,647(inclusive).(2^31 -1)

Long
Minimum value is -9,223,372,036,854,775,808.(-2^63)
Maximum value is 9,223,372,036,854,775,807 (inclusive). (2^63 -1)

SonalPM
  • 1,317
  • 8
  • 17