-1

I am having an if loop which is highlighted below. The problem is that even though "secondentry" contains "literature", then also the if loop is entered which is not correct. Am i missing anything?

here is my code:-

  if (strLine.contains(wID))
  {
      String splitarray[] = strLine.split("\t");
String firstentry = splitarray[0];
String secondentry = splitarray[1];

     **if(secondentry!="literature")**
                 {
          out.println ("Domain is: "+secondentry+"\n\n"+"<br/><br/>"); 
                  %>
        <INPUT TYPE="radio" NAME="r<%=k%>" VALUE="<%=wordID%>">
        <%
        out.println("Gloss= "+word1.getSynset().getGloss()+"<br/><br/>");
        %>
        <%
     }
  }
Nachiket Kamat
  • 75
  • 1
  • 4
  • 8

3 Answers3

0

You should use the method equals to compare String

!secondentry.equals("literature")
bobkilla
  • 121
  • 2
  • 9
0

(secondentry!="literature")

You checking here if pointer of secondentry equals pointer of literature. You should use equals function of strings. For example: secondentry.equals(stringTocheckWith).

Farseer
  • 4,036
  • 3
  • 42
  • 61
  • yes tht worked. thank you. i am familiar with asp.net so I did not figure this out. can you please give some reference to these conccepts – Nachiket Kamat May 12 '13 at 12:27
0

!secondentry.equals("literature") ;p

Jackson
  • 3,476
  • 1
  • 19
  • 29