When you already know the values at the time of creation, you can skip the new keyword and list them inside curly braces:
int[] scores = {90, 85, 78, 92, 88};
String[] colors = {"red", "green", "blue"};
Java infers the array length from the number of values you provide. The first example creates an array of length . The second creates one of length .
One restriction: this shorthand only works in the same statement as the declaration. If you separate the two lines, the compiler rejects it:
int[] scores;
scores = {90, 85, 78}; // compiler error
In that case, you need the full form: scores = new int[]{90, 85, 78};