Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# How to find the highest number using an array

Posted on 2003-12-01
Medium Priority
440 Views
Hello,

i have a problem which i have been trying to figure out for a couple of days but i can't seem to think of anyway of doing it, i am developing a little tool for myself to keep track of my scores in a sport i play...

The problem is here,

I have an array (size 11) with integers inside. I want to find the highest integer (i.e. score) in that array.

so for example if i have the following numbers in the array... 60, 12, 34, 56, 106 ... i would like to some how take the largest number out of the array which is 106 and store it in a int type variable.

This will allow me to keep track of my highest score. I have tried using a for loop but failed miserably, does anyone have an idea of how i can do this?

Thanks for your help.
0
Question by:Programmer_to_be
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• Learn & ask questions
• 4

LVL 86

Expert Comment

ID: 9851485
Are you sure it isn't homework? ;-)
0

LVL 86

Expert Comment

ID: 9851492
int max = Integer.MIN_VALUE;
for(int i = 0;i < int.length;i++) {
if (ints[i] > max)
max = ints[i];
}
0

LVL 86

Accepted Solution

CEHJ earned 400 total points
ID: 9851598
Woops

>>for(int i = 0;i < int.length;i++) {

should be

for(int i = 0;i < ints.length;i++) {

where 'ints' is your array of integers
0

Author Comment

ID: 9851729
Hi CEHJ

Thanks for the help, i can assure you it's not homework! (However it would be great if i was taught Java rather than having to self learn it!)

Thanks again.
0

LVL 86

Expert Comment

ID: 9851738
:-)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
###### Suggested Courses
Course of the Month10 days, 6 hours left to enroll

#### 722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.