0

I tried to declare fixed array objects for testing, to remove the need to reenter objects on every run.

The array test objects are like this:

studentList[0].setStudent("Mr", "Jason", "Lee", 00001, 01, 01,2001, 85, 75, 8, 65, 72.5, "D");
studentList[1].setStudent("Miss", "Candice", "Teo", 00002, 02, 02, 2002, 95, 95, 9, 90, 92.0, "HD");
studentList[2].setStudent("Mrs", "Sophie", "Chua", 00003, 03, 03, 2003, 65, 78, 7, 92, 81.6, "HD");
studentList[3].setStudent("Mrs", "Brendon", "Low", 00004, 04, 04, 2004, 95, 98, 7, 69, 80.1, "HD");
studentList[4].setStudent("Mr", "Clarance", "Yeo", 00005, 05, 05, 2005, 80, 76, 5, 59, 65.7, "C");
studentList[5].setStudent("Mr", "Adrian", "Tan", 00006, 06, 06, 2006, 70, 60, 4, 20, 40.0, "ND");
studentList[6].setStudent("Ms", "Debbie", "Toh", 00007, 07, 07, 2007, 60, 60, 7, 50, 56.0, "P");
studentList[7].setStudent("Miss", "Sarah", "Ho", 00008, 08, 08, 2008, 59, 61, 7, 62, 62.0, "N");
studentList[8].setStudent("Mr", "Aloysius", "Lim", 00009, 09, 09, 2009, 62, 63, 8, 69, 67.5, "C");
studentList[9].setStudent("Mrs", "Peggy", "Lo", 00010, 10, 10, 2010, 65, 67, 9, 72, 71.4, "D");

They are an array object containing

studentTitle (String),

studentFirstName (String),

studentLastName (String),

studentID (Long),

and the rest are scores of (Int) and lastly gradeof (String).


However, an error was shown stating:

integer number too large: 00008

integer number too large: 08

integer number too large: 08

for both on studentList[7] and studentList[8].


May I know what should be corrected? Thank you

user2864740
  • 60,010
  • 15
  • 145
  • 220
gymcode
  • 4,431
  • 15
  • 72
  • 128

1 Answers1

3

08 and 00008 are parsed as octal numbers, in which 8 and 9 are invalid digits. Remove the leading zeroes.

Eran
  • 387,369
  • 54
  • 702
  • 768
  • will there be an error if the input was stored by user input while the program runs instead of prefixed? – gymcode Mar 29 '15 at 08:07
  • @gymcode What do you mean? If the input integers are not prefixed by leading zeroes, there won't be any problem. – Eran Mar 29 '15 at 08:09