Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-30-2007, 05:27 PM
Member
 
Join Date: Jul 2007
Posts: 26
osval is on a distinguished road
How to get the max value from a list
I need to find the max value from a lot of records. this is my code

Code:
double max = 0.0; for (int i=1; i<size; i++){ max = data[0]; if (data[i]>max) { max = data[i]; } System.out.println(max);

But it saves the last highest number on the list and it doesn't compare the values.
How can I get it to find the max value from the entire list?
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-30-2007, 06:43 PM
Senior Member
 
Join Date: Jul 2007
Posts: 134
brianhks will become famous soon enough
Code:
double max = 0.0; max = data[0]; for (int i=1; i<size; i++) { if (data[i]>max) { max = data[i]; } System.out.println(max);
That should work better.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Members List Eranga Suggestions & Feedback 11 01-17-2008 11:41 AM
To display as a list yuvi461 New To Java 2 01-09-2008 01:06 PM
Linked List rnavarro9 New To Java 0 11-29-2007 04:42 AM
list Zensai New To Java 3 11-20-2007 08:22 AM
Link List one198 New To Java 0 10-14-2007 02:33 PM


All times are GMT +3. The time now is 12:13 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org