Tony Morris <dibblego@optusnet.com.au> scribbled the following:[color=blue]
> "D E" <nothing@nothing.com> wrote in message
> news:F6Xnc.25872$vz5.23303@nwrdny01.gnilink.net...[color=green]
>> Ok this post was unclear... read below
>>
>> "D E" <nothing@nothing.com> wrote in message
>> news:02Xnc.25871$vz5.17045@nwrdny01.gnilink.net...[color=darkred]
>> > Ok the subject line is basically the question. Obviously this[/color]
>> .....
>> "this" being this line of code:
>>
>> //begin code segment
>> String strComparer = "test2";
>> if ("test1".equals(strComparer) ) then
>> System.out.println("strComparer should output \"test1\"");
>> //end code segment
>>
>> won't work.[color=darkred]
>> > What is the technical reason?
>> >
>> > Is it because here, "test1" is sort of like a static object now?
>> >
>> > What exactly is "test1" in this case?
>> >
>> > Thanks.[/color][/color][/color]
[color=blue]
> The term "won't work", "doesn't work", etc. etc. has no meaning when it
> comes to problem resolution.
> So, I will speculate (since it is forced by your lack of contextual
> information).[/color]
[color=blue]
> It doesn't compile ?
> Incorrect, yes it does.[/color]
No it won't. Have you tried to compile it? I have.
[joona@teletran-1 joona]$ cat test.java
public class test {
public void method() {
//begin code segment
String strComparer = "test2";
if ("test1".equals(strComparer) ) then
System.out.println("strComparer should output \"test1\"");
//end code segment
}
}
[joona@teletran-1 joona]$ javac test.java
test.java:5: not a statement
if ("test1".equals(strComparer) ) then
^
test.java:6: ';' expected
System.out.println("strComparer should output \"test1\"");
^
2 errors
[color=blue]
> The expression evaluates to false ?
> Yes, it does.[/color]
[color=blue]
> The output is unexpected ?
> Well, to me, it's perfectly fine, what were you expecting ?[/color]
Expression evaluation and output are not defined for programs that do
not compile.
[color=blue]
> Java doesn't work ?
> <sarcasm>Oh, you found the bug in boolean expressions giving ad hoc
> behaviour that all of use millions have spent years looking for</sarcasm>[/color]
This is true.
[color=blue]
> Without more information, speculative answers are all you'll get.[/color]
--
/-- Joona Palaste (palaste@cc.helsinki.fi) ------------- Finland --------\
\--
http://www.helsinki.fi/~palaste --------------------- rules! --------/
"As we all know, the hardware for the PC is great, but the software sucks."
- Petro Tyschtschenko