No democracy among Java objects?

kummer (ciao)
Hi, jabber, thanks a lot for your answer.
I totally agree with you, but look at the following cases:

1) String s1=new String("abc");
String s2=new String(edf");
This is a standard Java statement.
Of course, compile and run well.

2) "abc"=="edf";
Complie and run well.
A little bit strange since we compare two objects(not references), nevertheless it is understandable if noticing special properties of anonymous strings.

3) new String("abc")==new String("edf");
doesn't compile.
Excluded Java standards. However,

4) For all wrapper classes like
new Boolean("TRUE")==new Boolean("hi");
compile and run well!

So democracy doesn't exist, there are some special objects having extraordinary rights.
Do you agree?

2001-1-3 -04:00

回到话题: Help: the following doesn't compile, why?

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论