• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

.compiled but runtime error.Head First Java Chapter 11, example on page 346

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

>compiles but does not run.i have tried changing `args[0]`to `args[1]`
still the output of cmd is this:
H:\jp>java ma
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at ma.main(ma.java:7)




 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

chaitanya ashtekar wrote: >compiles but does not run.i have tried changing `args[0]`to `args[1]`
still the output of cmd is this:
H:\jp>java ma
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at ma.main(ma.java:7)



Well, since you didn't pass any actual parameters to the program, there isn't an args[0]. And likewise, there isn't an args[1] either.

Henry
 
chaitanya ashtekar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but i have written it exactly as written on Head First Java Chapter 11, example on page 346..
 
chaitanya ashtekar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

chaitanya ashtekar wrote: >compiles but does not run.i have tried changing `args[0]`to `args[1]`
still the output of cmd is this:
H:\jp>java ma
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at ma.main(ma.java:7)



Well, since you didn't pass any actual parameters to the program, there isn't an args[0]. And likewise, there isn't an args[1] either.

Henry



okay.thank you.got what you meant.i did not pass any parameters in cmd
reply
    Bookmark Topic Watch Topic
  • New Topic