• Register
0 votes
583 views

Problem :

I am getting bellow error while compiling Arraylist

exception in thread "main" java.lang.indexoutofboundsexception: index: 0, size: 0

6 5 3
6,930 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution:

It seems "ArrayList<ArrayList<Integer>> " this list doesnt have any element at the (0)th postion and now the compiler throws "out of bounds exception" as it doesn't find any element in that postion.

when you try executing bellow code

list.get(0).set(placeHolder.get(k), (int) (Math.random() * (99999) + 1)); 

 your list is empty so you need to iterate through the inner list to set the values for the list.

Further Readings:

https://github.com/owlcs/owlapi/issues/724

9 7 4
38,600 points

Related questions

0 votes
1 answer 24 views
0 votes
1 answer 35 views
0 votes
1 answer 5 views
5 views
Problem: public Collection<AdDistribution> getAdDistribution(byte srch, byte cont) throws IndexOutOfBoundsException { List<AdDistribution> mediums = new ArrayList<>(); List<AdDistribution> adDistribution = new ArrayList<>(); adDistribution.add(AdDistribution.SEARCH); adDistribution.add( ... ); } return mediums; }I am getting the error java.lang.IndexOutOfBoundsException: Index: 0, Size: 0.
asked Feb 20 Ali 7.2k points
0 votes
1 answer 14 views
14 views
Problem: I am getting the error java.lang.IndexOutOfBoundsException: Index: 0, Size: 0. public Collection<AdDistribution> getAdDistribution(byte srch, byte cont) throws IndexOutOfBoundsException { List<AdDistribution> mediums = new ArrayList<>(); List<AdDistribution> adDistribution = new ... ); mediums.set(0, adDistribution.get(0)); mediums.set(1, adDistribution.get(1)); } return mediums; }
asked Feb 3 Ali 7.2k points
0 votes
1 answer 4 views
4 views
Problem: Why I got the error : exception in thread "main" java.lang.stringindexoutofboundsexception: string index out of range: 1 HELP! I need help understanding this error. Can someone please help fix this, I am new in java: exception in thread "main" java.lang.stringindexoutofboundsexception: string index out of range: 1 Any anyone ideas on what I need to do to fix this? Thanks!
asked Mar 1 Ali 7.2k points
0 votes
1 answer 67 views
0 votes
1 answer 46 views
46 views
Problem : Currently I am learning Java. I have written code in Java but it gives me below error &ldquo;Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Minesweeper.main(Minesweeper.java:5)&rdquo;. I am unable to understand above error. How can I fix above error.
asked Feb 22, 2020 mphil 2.3k points
0 votes
1 answer 14 views
14 views
Problem: I am a beginner, started learning Java recently. While working with arrays, my program generated the following error: java.lang.indexoutofboundsexception: invalid index 1, size is 1 Following is the code that I am trying to execute: public class Main { public static void main(String[] ... ++) { System.out.println(nums[i]); } } } I do not know what the problem is with my program. Any help?
asked Dec 4, 2020 Code Learner 7k points
0 votes
1 answer 1 view
1 view
Problem : why this happened with me ? Getting Java Exception in thread "main" java.lang.error: unresolved compilation problem:.
asked 1 day ago Wafa Abu Yousef 2.3k points
0 votes
1 answer 6 views
6 views
Problem: Why I got the error : exception in thread "main" java.lang.numberformatexception: empty string How to fix this erro:exception in thread "main" java.lang.numberformatexception: empty string Can someone please help fix this, exception in thread "main" java.lang.numberformatexception: empty string Any ideas on what I need to do to fix this? Thanks!
asked Feb 28 Ali 7.2k points