balagosa
September 15th, 2008, 12:46 PM
<%
String strGender = rs.getString("gender");
if(strGender.equals("male"))
{
out.println("1");
}
if(rs.getString("gender").equals("male"))
{
out.println("2");
}
%>
In theory, the output should be "12". But guess what, only "2" was printed. I spent hours of debugging because I was supposed to use strGender.equals but the results only ended up in frustrations. So I made experiments, and the direct comparison of rs.getString was the result that worked.
Can anyone explain to me why?
String strGender = rs.getString("gender");
if(strGender.equals("male"))
{
out.println("1");
}
if(rs.getString("gender").equals("male"))
{
out.println("2");
}
%>
In theory, the output should be "12". But guess what, only "2" was printed. I spent hours of debugging because I was supposed to use strGender.equals but the results only ended up in frustrations. So I made experiments, and the direct comparison of rs.getString was the result that worked.
Can anyone explain to me why?