File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to find the smallest element in an array? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to find the smallest element in an array?" Watch "How to find the smallest element in an array?" New topic
Author

How to find the smallest element in an array?

Nick Hallloran
Greenhorn

Joined: Feb 09, 2010
Posts: 19
The question is to write a method that finds the smallest element in an array of integers. I have to use 1, 2,4,5,10,100,2,-22 to test the method. My program is able to compile but it wont run. If anyone could help it would be much appreciated.

Here is my code:

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

My program is able to compile but it wont run


What does that mean exactly? Errors, unexpected output? No output? You have to give more details. Also, do you really not indent your code? It makes it terribly difficult to read.


GenRocket - A Test Data Generation Platform
Gary Ba
Ranch Hand

Joined: Oct 23, 2009
Posts: 150

I ran it and it compile and run okay for me.

did you try(assuming compiler set up correctly)...

javac fileName.java
then..

java fileName?


star chaser..
Nick Hallloran
Greenhorn

Joined: Feb 09, 2010
Posts: 19
haha wow i cant believe i missed that one....Thanks Alot!
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Nick Hallloran wrote:haha wow i cant believe i missed that one....Thanks Alot!


Missed what?
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 917

Gregg Bolinger wrote:
Nick Hallloran wrote:haha wow i cant believe i missed that one....Thanks Alot!


Missed what?


possibly:
"java fileName.java" instead of "java fileName"


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to find the smallest element in an array?
 
Similar Threads
Drawing a Histogram ( I know its been covered and I have read through those posts)
Two dimensional array total and sort
need help sorting Integer objects
Wanted some help about arrays
summing each row in a 2-dimensional array