wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 15299
    
    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 - Experts at Building Test Data
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: 15299
    
    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]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to find the smallest element in an array?
 
Similar Threads
summing each row in a 2-dimensional array
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