Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with my code to find MinOfAll numbers

 
Hmbj Shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I am new to Programming world and so to Java,

I tried my hands on writing the following code to find minimum of all the numbers entered via command prompt,
but I am getting the error

Exception in thread "main" java.lang.ArrayIndexOutOfBound Exception :5 at MinOfAll.main

Kindly tell me where am I going wrong?

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
instead of doing Integer.parseInt(args[0]); at line 5 try putting a high number in there, 999 for example, so that you know for sure that some of the numbers you are passing in will be lower. Also inside you for loop don't add 1 to i.

-Hunter
 
Hmbj Shah
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You Hunter, it worked.

Appreciate it !!

 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4402
251
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Maverick Hs", please check your private messages regarding an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic