Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 28 of 28

Thread: Splitting up array's:

  1. #26
    Member
    Join Date
    Apr 2014
    Posts
    219
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default Re: Splitting up array's:

    29
    Could not open the file java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:635)
    at java.util.ArrayList.set(ArrayList.java:426)
    at CountWinnerPoker.splitArray(CountWinnerPoker.java: 48)
    at CountWinnerPoker.readFile(CountWinnerPoker.java:25 )
    at CountWinnerPoker.main(CountWinnerPoker.java:69)

  2. #27
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: Splitting up array's:

    Well, the error message you get is very exact.
    You attempt to use the "set" method of the ArrayList class with in invalid index.
    Read the documentation for the arraylist; you can only use set on an index when the list has at least a size equal to the index + 1.
    Your array list however has a size of 0 and thus you can not use the set method with any index.

    What you want to do is probably "add" elements to the list.

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Splitting up array's:

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:635)
    at java.util.ArrayList.set(ArrayList.java:426)
    at CountWinnerPoker.splitArray(CountWinnerPoker.java: 48)
    At line 48 the code called the set() method with an invalid value. See post#27 for explanation.
    If you don't understand my answer, don't ignore it, ask a question.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Help splitting into two different classes.
    By rehrnsberger in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 23rd, 2012, 11:05 AM
  2. Splitting text into several components
    By clydefrog in forum File I/O & Other I/O Streams
    Replies: 31
    Last Post: February 23rd, 2012, 12:50 PM
  3. Splitting String
    By JuLiAnc in forum What's Wrong With My Code?
    Replies: 3
    Last Post: December 17th, 2011, 10:23 AM
  4. Splitting an Array?
    By ThatGuy1234 in forum Java Theory & Questions
    Replies: 1
    Last Post: January 19th, 2011, 08:20 AM
  5. Splitting File into Array
    By Scottj996 in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: March 3rd, 2010, 11:48 AM