• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Queue

 
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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





 
Ranch Hand
Posts: 40
Eclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic