Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

command prompt arguments

 
Erkki Veps�l�inen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've made a program that takes arguments from the command prompt. I use the args as conditions for if statements. Now I want to give from 2 to 4 arguments. The problem is that my array gives an Arrayindexoutofboundsexception if I want to give for example only 2 arguments since my if statements contain conditions for args[2] and args[3] aswell.

Suggestions?

-Erkki
 
Petr Blahos
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
args.length will tell you the number of arguments.
Remember that args is a totally standard java array
of Strings.

P.
 
Erkki Veps�l�inen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, works out fine

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic