• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

ArrayIndexOutOfBoundsException

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I am recieving an error in my code that the information within my array is out of bounds. This array is supposed to contain 3 parts of information, email, firstname, and lastname. However, any part other than 0 seems to be out of bounds and I am confused on what to do from there. My instructor just threw all this code at us without a thorough explanation of how it works.

There a bunch of Instructors/classes so I will include the ones I think are necessary.

Tester class:


Error:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 7
at controller.CourseFileHelper.getInstructor(CourseFileHelper.java:73)
at controller.CourseFileHelper.readFile(CourseFileHelper.java:40)
at tests.CourseFileHelperTest.main(CourseFileHelperTest.java:79)
 
Saloon Keeper
Posts: 9717
79
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Without seeing a sample of "courses.txt" it would be hard to say.
 
Carey Brown
Saloon Keeper
Posts: 9717
79
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
 
Nathan Montgomery
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carey Brown wrote:Without seeing a sample of "courses.txt" it would be hard to say.


12345|BIO101|11:15|12:55|Wanda Jean Smith wsmith@dmacc.edu|Building : 3 Room Number: 17 Campus: Ankeny Type: Science Lab Capacity: 22
23456|CIS171|10:10|12:20|Wilma Fitz wfitz@dmacc.edu|Building : 8 Room Number: 17 Campus: Ankeny Type: Computer Lab Capacity: 25
29876|LIT105|15:15|16:30|Emily Theo etheo@dmacc.edu|Building : 2 Room Number: 12 Campus: Urban Type: Classroom Capacity: 18

This is the exact format of courses.txt, I need firstname,lastname, and email for the Instructor which seems to be in positions 4,5,and 6.
 
Carey Brown
Saloon Keeper
Posts: 9717
79
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would seem that your method is not even getting the field with the instructor in it. Besides that, if it had, the delimiters you've defined for split aren't even present in the instructor string. I suggest adding lots of print statements because you think you know what your code is doing but it's not.
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic