compare strings

String a ="53.235"
String b ="95"

how to compare them and get b is greater than a. 95>53.235
there is Interger.getInt("53.235"), but 53.235 is not int.


please help, thanks
keepworkingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrigankCommented:
Float.getFloat("95").compareTo(Float.getFloat("53.235"))
mrigankCommented:
Sorry

Float.valueOf("95").compareTo(Float.valueOf("53.235"))
hoomanvCommented:
Double.parseDouble(a).compareTo(Double.parseDouble(b));
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

mrigankCommented:
Returns:
the value 0 if anotherFloat is numerically equal to this Float; a value less than 0 if this Float is numerically less than anotherFloat; and a value greater than 0 if this Float is numerically greater than anotherFloat.

From javadocs

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vinod_VijayanVinCommented:
use Float.parseFloat or Double.parseDouble

 
WelkinMazeCommented:
you can use
float aa = Float.parseFloat(a);
float bb = Float.parseFloat(b);
and after that compare the float values.
mrigankCommented:
>> hoomanv
Double.parseDouble returns a double and not a Double object.
valueOf should be used here.

or

Float.compare(Float.parseFloat(a), Float.parseFloat(b));
Double.compare(Double.parseDouble(a), Double.parseDouble(b));
hoomanvCommented:
mrigank
you are rigth ;-)
WelkinMazeCommented:
If we have
float aa = Float.parseFloat(a);
float bb = Float.parseFloat(b);

the comparison could be done simply by <, > and =
mrigankCommented:
:-) no worries.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.