This week's book giveaway is in the Java 9 forum.
We're giving away four copies of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications and have Sander Mak & Paul Bakker on-line!
See this thread for details.
Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!