This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes max value of 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 » Swing / AWT / SWT
Bookmark "max value of an array" Watch "max value of an array" New topic

max value of an array

Steffen K

Joined: May 15, 2001
Posts: 3
i have an array with int values and want the maximum value of this array... are there any methods from java to make this available... any ideas?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Use "length". For example:
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
"Steffen K",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Aleksey Matiychenko
Ranch Hand

Joined: Apr 03, 2001
Posts: 178
Length returns the length of an array not the max value of the elements in the array.
A simple loop through would calculate max.
It is sorta covered in the JavaRanch Style Guide.
subject: max value of an array
Similar Threads
How to make array elements final
Question about Master Exam question (array usage)
nullpointer exception
toArray(Object [] a) ?
Is there any collection to store the premitive data type?