This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help with my code to find MinOfAll numbers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with my code to find MinOfAll numbers" Watch "Help with my code to find MinOfAll numbers" New topic
Author

Help with my code to find MinOfAll numbers

Hmbj Shah
Greenhorn

Joined: Apr 19, 2010
Posts: 3
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?



HS
Hunter McMillen
Ranch Hand

Joined: Mar 13, 2009
Posts: 492

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


"If the facts don't fit the theory, get new facts" --Albert Einstein
Hmbj Shah
Greenhorn

Joined: Apr 19, 2010
Posts: 3
Thank You Hunter, it worked.

Appreciate it !!

Devaka Cooray
ExamLab Creator
Sheriff

Joined: Jul 29, 2008
Posts: 3599
    
  78

"Maverick Hs", please check your private messages regarding an important administrative matter.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
 
Have you checked out Aspose?
 
subject: Help with my code to find MinOfAll numbers
 
It's not a secret anymore!