• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(B&S) Error in my cache(ArrayList)

 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
In my Data.java i have the following code that opens the datafile accordingly and attempts to make use of a cache P.s If i violate any code pls feel free to edit my posts accordingly):


When i try to run it i get the following error:





D:\Developer>java -jar runme.jar alone
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size:
0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.set(ArrayList.java:338)
at suncertify.db.Data.getRecords(Unknown Source)
at suncertify.db.Data.<init>(Unknown Source)
at suncertify.db.DataAdapter.<init>(Unknown Source)
at suncertify.remote.ContractorConnector.getLocal(Unknown Source)
at suncertify.gui.GUIController.<init>(Unknown Source)
at suncertify.gui.MainWindow.<init>(Unknown Source)
at suncertify.gui.ApplicationRunner.<init>(Unknown Source)
at suncertify.gui.ApplicationRunner.main(Unknown Source)


I really dont know how to handle the problem. At first i figured it was that i didnt set an initial capacity for the arraylist, but right now after doing that it doesnt still change. Your insight into the problems will highly be appreciated
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The set() method replaces the element at the specified position in this list with the specified element. You do not have any element in the array now.

Try to use add() method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic