if condition

Hi all

my code is like this

String name = request.getParameter("txtName");

out.print("Hello "+name);

if(name == "Sree")

{

out.print("Entered");

}

I passed the value of a text box with name txtName. I entered the word Sree.

It is showing as Hello Sree. but the Entered string is not displaying

[354 byte] By [codename47a] at [2007-11-27 10:30:36]
# 1

Don't compare strings using ==, use the .equals() method

georgemca at 2007-7-28 18:04:04 > top of Java-index,Java Essentials,New To Java...
# 2

thanks it works

codename47a at 2007-7-28 18:04:05 > top of Java-index,Java Essentials,New To Java...
# 3

and beware that strings are case sensitive.

Manuel Leiria

manuel.leiriaa at 2007-7-28 18:04:05 > top of Java-index,Java Essentials,New To Java...