Help with Arrays Please


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Help with Arrays Please

  1. #1
    Join Date
    Jun 2005
    Posts
    2

    Help with Arrays Please

    Code:
    int scores[] = {18, 19, 28, 13, 5, 25, 35};
    I am trying to display the lowest score only in JOptionPane.showMessageDialog.

    The lowest score which is 5.

    How do I do it?
    Please help.

    Thanks in advance.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Code:
    int low=Integer.MAX_VALUE;
    for (int i=0; i<scores.length; i++) {
      if (scores[i] < low) low=scores[i];
    }
    // display low in optionpane
    eschew obfuscation

  3. #3
    Join Date
    Jun 2005
    Posts
    2
    thank a lot!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center