• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
chaitanya ashtekar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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)



 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!