DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  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.

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links