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

I say they are the same.
I think (in Java and C#) using the {} calls "new".
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
Be a part of the DaniWeb community

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