[java programming] Re: comparing strings

2009-07-22 Thread pincer prince
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

[java programming] Re: comparing strings

2009-07-22 Thread Wayne Barker
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

[java programming] Re: comparing strings

2009-07-22 Thread Maria Vargas
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

[java programming] Re: comparing strings

2009-07-22 Thread pacior
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(

[java programming] Re: comparing strings

2009-07-22 Thread SAMMY REYES
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

[java programming] Re: comparing strings

2009-07-22 Thread Paul
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

[java programming] Re: comparing strings

2009-07-22 Thread Babu Rajendran
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