Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Positive numbers

Status
Not open for further replies.

sjaakdelul

IS-IT--Management
Sep 19, 2002
43
NL
Ok, I know how to read some numbers in java, for example with the 'MyInput' methode...
But how can java decide if the numbers are positief (or negative) and which of the (5) numbers is the bigest number of them?

I don't expect a whole code, but just a few words, which can help me to make the code or search on the internet...

Thx
 
Try compiling and running this :

public class Test {
public static void main(String args[]) {
if (Integer.parseInt(args[0]) > Integer.parseInt(args[1])) {
System.out.println("first number bigger - " +Integer.parseInt(args[0]));
}
}
}

Run it by passing two args on command line like "java Test 123 -34"

Java "knows" inherently from its primitive data types capability whether numbers are higher or lower than another integer you are comparing it to. The "java.util.Integer" class is a wrapper class around the primitive data type integer. (Integer.parseInt converts a String to an int btw)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top