thanks for all the help guys
ben
--~--~-~--~~~---~--~~
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to
javaprogrammingwithpassion-unsubscr...@googlegroups.com
For more options, visit
Convert the age to an integer and compare just like typical numbers
int age1int = Integer.parseInt(age1);
int age2int = Integer.parseInt(age2);
maxage = (age1int > age2int) ? age1int : age2int;
- Original Message -
From: "ben"
To: "Free Java Programming Online Training Course By Sang
you cannot compare values in string format
you have to convert the 'String' type to 'int' type and then compare it with
another 'int'
There is a method to convert in the Integer class called parsInt()
for example:
int age = Integer.parsInt(agestr);
--- El mié 22-jul-09, ben escribió:
De: be
If Your data is age, then You have to compare ints, not Strings..
You do comparision basically in two steps:
First is: Cast from String to int
Second: compare ints
1*
String a = "7";
String b = "8";
int ia = Integer.parseInt(a);
int ib = Integer.parseInt(b);
if ( ia != ib )
System.out.println(
hi ben,
1) You can use equal method for string comparison -ex.
age.equal(ageInputString)
2) In order to get the largest value, first you need to convert it from string
to integer (ex. int ageint = Integer.parseInt(age)) . To get the maximum
value, you may need to use math.max() method or con
You must parse of String to Integer value. The Integer class, in
java.lang has a static method that does this conversion.
Integer.toString, whit a one parameter, a string, or two parameter,
String and radix of this number representation by that string.
String strnumber = "25";
int n = Integer.par
Hi Ben,
You can use the static method parseInt from the Integer class to convert the
String to an integer and then you can compare.
For example:
String age = "10";
int myAge = Integer.parseInt(age);
Regards,
Babu
On Wed, Jul 22, 2009 at 10:02 PM, ben wrote:
>
> hi all,
>
> i want to know how