Yep, stupid Java problem.

You need to use .equals("and") to compare the strings.  the "=="
operator tests for reference equality.  You have two String objects in
memory, which have different references, so the "==" test fails. 
However, if you tell them to compare themselves, they'll figure out
they mean the same thing.

You can use internalize() on both to get the One True String for the
system, but you really don't want to bother with that here.

-Kevin
--- Michael Ryan Bannon <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> This might be just a stupid Java problem I'm overlooking.
> 
> The snippet below deals with a TEXT_NODE with a String value "and":
> 
> ============================================
> ...
> 
> // Output the value of a text node.
> // This should, and does, output "and".
> System.out.println(node.getNodeValue());
> 
> // Test the node.
> if (node.getNodeValue() == "and")
>     System.out.println("it worked");
> 
> ..
> ============================================
> 
> Now, I've confirmed that it's a text node before the snippet.  The
> first println outputs "and".  However, the "if" statement is false,
> so I never see "it worked".  How is this possible?
> 
> This seems so trivial...what am I missing?
> 
> Thanks in advance,
> 
> Ryan


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to