It's not a secret anymore!
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
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.
I agree. Here's the link:
subject: max value of an array
It's not a secret anymore!