I am a beginner to Java and have a question wrt to how arrays can be declared in Java and was looking back through some Stack Overflow questions.
In the answer to one question it suggests that there are three ways to declare an integer array.
int[] myIntArray = new int[3];
int[] myIntArray = {1, 2, 3};
int[] myIntArray = new int[]{1, 2, 3};
I understand the concept but I am a little confused wrt to the last two examples:
int[] myIntArray = {1, 2, 3};
int[] myIntArray = new int[]{1, 2, 3};
What is the difference between the two? - can anyone give me a practical example of when one is better than the other and for which used case.