This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum 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
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 490

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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2726
    
    3

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


Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Help with my code to find MinOfAll numbers
 
Similar Threads
Why can't I add 1 + 1?
Prime numbers
Exception Handling
Calendar class methods give weird results
For the Love of Loops!