[jdom-interest] passing string from jdom tree to if statement

Trond Fuglestad tfuglest at c2i.net
Wed May 15 08:53:31 PDT 2002


I am trying to get the contents of a an element in a jdom tree, and then use
this value (a String) in an if-statement.
My problem is, that when i try to use this String in the if-statement, it
does not match, and the else-statement is printed.
What I find strange is that when I use System.out.println it prints the
right value.
Very grateful if anyone can help me with this!

Here is the code:

private void docType (Document doc)
  { Element chk = doc.getRootElement();
    String type =
chk.getChild("header").getChild("command").getTextNormalize(); //Or
getText() or getTextTrim()

    System.out.println(type);  //Used for testing purposes, prints Send
    System.out.println(type.length()); //Used for testing purposes, prints 4
    if (ok == "Send")
    {
      System.out.println("Send loop");
    }
    else
    {System.out.println("feil");}


Trond Fuglestad




More information about the jdom-interest mailing list