• Post Reply Bookmark Topic Watch Topic
  • New Topic

ArrayIndexOutOfBoundsException: 1 at readFile.main  RSS feed

 
Yudhistra Verma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is due to when a line is read from the stream and subsequently split into an array. Your code does not check how many elements are in the array. You simply access each element after the split. You need to run your code in debug to find out why the array does not contain the number of elements you are expecting it to.
 
Yudhistra Verma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
debug:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at readFile.main(readFile.java:42)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Still same message ...Can't understand why is it so..
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println is your best friend. print out the length of the array before you acess it. print out some of the elements. Make sure it really holds what you think it holds.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!