comparing integers


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: comparing integers

  1. #1
    Join Date
    Jun 2004
    Posts
    24

    comparing integers

    Hi people i need help on some java and im fairly new to this. I'm not sure how to compare 5 integers and to see which one is the smallest and which one is the biggest. They say use around 8 if statements, I want to do it using if statements but im not sure how to. Please get backt o me on this one thanks.

  2. #2
    Join Date
    May 2004
    Posts
    219
    The best way is to use a for loop, but if they want you to use a bunch of if statements, that would work too. I would do something like this:

    Code:
    int highest = 0;
    if (blah > highest)
         highest = blah;
    if (blah2 > highest)
         ...
    Same concept with lowest.

    Edit: Or sort and pull the extremes

  3. #3
    Join Date
    Jun 2004
    Posts
    24
    thanks a lot. I appreciate it.

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