• Post Reply Bookmark Topic Watch Topic
  • New Topic

Queue  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Is this line about the main thread?


when I run this code, It throws an exception:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at queue.Countdown.main(Countdown.java:13)
Java Result: 1




 
Buddhika Mawella
Ranch Hand
Posts: 40
Eclipse IDE Java Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes,
is about main thread according to your program. But the exception you are getting is not a problem of that thread.Have can you seen that main method of your program has an argument of String array ,String[] args. and you are trying to get the first element of args array by calling args[0] in 4th line of your code.Trying to retrieve an element from an empty array generates an ArrayIndexOutOfBoundsException.To avoid this error you have to provide a command line argument that can be parse to an interger (eg: 10,29).Search google for "command line arguments java" to find how you can give command line arguments to a java program.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!