String compare

Hi guys,

What is the right way to compare two strings?

If I want to know, if "abc" comes before or after "abd" in directory, how do I do it?

if (Integer.parseInt("abc")>Integer.parseInt("abd"))

{

}

Is this the only way to do it? What happens if the strings are really long?

Is there any better way to do it?

Thanks a lot,

Rishi

[391 byte] By [new_rishia] at [2007-11-27 9:47:09]
# 1
Use compareTo(String). String implements the Comparable interface. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Comparable.html
hunter9000a at 2007-7-12 23:59:00 > top of Java-index,Java Essentials,New To Java...
# 2
> Integer.parseInt("abc")What number are you expecting here?
BigDaddyLoveHandlesa at 2007-7-12 23:59:00 > top of Java-index,Java Essentials,New To Java...
# 3
#! /usr/bin/groovyassert ('abc' > 'abd') == falseHeh heh heh.~
yawmarka at 2007-7-12 23:59:00 > top of Java-index,Java Essentials,New To Java...