What (if anything) is the difference between these two?

String[] sa = {"ABC"};
String[] sa = new String [] {"ABC"};

Recommended Answers

All 3 Replies

The one thing I dislike about Java: repeating yourself.

- WolfShield

Hmmm...
I say they are the same.
I think (in Java and C#) using the {} calls "new".
...testing...
Well, I created two programs with the same variable names and same class names, compiled them and ran fc /b over them:
"FC: no differences encountered" at the byte level.

commented: Excellent reply, good research +14

The byte code test looks like a definitive answer to me. Case closed. Thanks Tom.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.