int[] a = new int[]{1,2,3};
int[] b = {1,2,3};
What difference between a and b? Am I right that first is object and ‘a’ is a link, and second is a primitive type and ‘b’ is a variable? But what advantages/disadvantages have first array?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In an initialization like you have there, there is no difference between them at all. They result in the same bytecode. Note that you have to use the first form in an assignment, though:
No, in both cases, you have a variable (
a,b) which is a reference to the array.