• Register
0 votes
57 views

Problem :

Currently I am learning Java. I have written code in Java but it gives me below error

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Minesweeper.main(Minesweeper.java:5)”.
I am unable to understand above error. How can I fix above error.
8 4 2
2,300 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I read your question on Java. As you are beginner in java you are facing these exceptions.
I think you have done two mistakes in your java code:

First mistake is you are facing the ArrayIndexOutOfBoundsException :0 it clearly  informs that your code is  trying to reach the array value with the index value which out of array range.

Second mistake is you want to use the command line arguments but you may not be entering any arguments as the parameter. The main method supposes needs 5 parameters in order to run without any error but with zero parameters. args[0]args[1]args[2], args[3] and args[4]   means You have the array with name as args[] and now you want to reach 0th, 1st ,2nd,3rd ,4th   elements of your args[] named array. But  if you are providing zero command-line parameter then you are trying to reach the null value and so you are facing;

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Minesweeper.main(Minesweeper.java:5)”.
5 2 1
4,980 points

Related questions

0 votes
1 answer 25 views
0 votes
1 answer 46 views
0 votes
1 answer 12 views
12 views
Thank you in advance for any help?
asked Jan 5 TeamScript 13.5k points
1 vote
1 answer 23 views
23 views
Problem : I have very recently started to learn programming in Java. I am trying to execute my java code but I am facing the below error. “Exception in thread "main" java.lang.arrayindexoutofboundsexception:” I am unable to understand above error. Please find below my code: ... according to my debugger*/ myodd[j] = input[i]; j++; } return myodd; } Please help me in fixing above error.
asked Mar 30, 2020 morrisBson 3.2k points
0 votes
1 answer 112 views
112 views
Problem : I am a beginner to Java programming. While executing my program i got below error exception in thread "main" java.lang.arrayindexoutofboundsexception: 10
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 37 views
0 votes
1 answer 76 views
0 votes
1 answer 669 views
669 views
Problem : I am getting bellow error while compiling Arraylist exception in thread "main" java.lang.indexoutofboundsexception: index: 0, size: 0
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 1 view
1 view
Problem: anyone who know this problem please help? exception in thread "main" java.lang.runtimeexception: stub!
asked 20 hours ago Rohit kr 14.7k points
0 votes
1 answer 10 views
10 views
Problem: Can anyone tell me the solution of this problem? exception in thread "main" java.lang.unsupportedoperationexception: not supported yet.
asked Mar 25 Ifra 24.4k points