Strings in Switch .. and classes
Paul Benedict
pbenedict at apache.org
Wed Dec 16 10:51:39 PST 2009
Tom,
On Wed, Dec 16, 2009 at 12:37 PM, Tom Hawtin <Thomas.Hawtin at sun.com> wrote:
> Paul Benedict wrote:
>
>> Class c = o.getClass();
>> if (c instanceof String) { .. }
>
>> Can be de-sugared into the new String switch:
>>
>> switch (object.getClass().getName()) {
>> case "java.lang.String":
>
> Class names are not unique.
>
Can you expound on this some more? I am surprised, so I want to hear
more about it. I thought these two are equivalent, no?
boolean x = c instanceof String;
boolean y = c.getName().equals("java.lang.String");
Paul
More information about the coin-dev
mailing list