how to comapare 2 strings

hi all,i want to compare two emails whether they are same or not .how can we write a function to compare two strings ?thanks in advance.
[157 byte] By [vicky_sa] at [2007-11-26 18:39:48]
# 1
equals("string");
qUesT_foR_knOwLeDgea at 2007-7-9 6:13:50 > top of Java-index,Java Essentials,Java Programming...
# 2
You don't need to. There are two methods in the String class, equals and compareTo which do it for you.
malcolmmca at 2007-7-9 6:13:50 > top of Java-index,Java Essentials,Java Programming...
# 3

I guess this question belongs in the "New To Java" forum, but anyway: the method has been written for you, it's in the String class and is called equals.

String s1 = "joe@ajax.com";

String s2 = "john@acme.com";

if (s1.equals(s2)) System.out.println("they are equal");

For email addresses, you may want to use equalsIgnoreCase() instead.

OleVVa at 2007-7-9 6:13:50 > top of Java-index,Java Essentials,Java Programming...