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

O'neil, Jerome joneil at cobaltgroup.com
Wed May 15 09:01:18 PDT 2002


Your problem isn't with JDOM, it's how you are evaluating equality of your
string.

Try

if(ok.equals("Send")){
	...
}


-----Original Message-----
From: Trond Fuglestad [mailto:tfuglest at c2i.net]
Sent: Wednesday, May 15, 2002 8:54 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] passing string from jdom tree to if statement


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

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020515/4ca34f7f/attachment.htm


More information about the jdom-interest mailing list