For the following line of code:
int x [ ] = new int [5]
Why is the second int necessary? Is the second type-declaration not always the same as the first?
On this specific case it may seem verbose and redundant, but since we're dealing with OO language, it's very likely (and useful) to run into declarations like:
Shape shape = new Triangle(); //where Triangle implements Shape interface
Same reason goes here, an Array could be of general type and contain items of different types, or, different type of arrays (that extend the same type). For example:
Number[] tmpNumbersArray = new Integer[10]; //
You can try this, if you have the values at compile time:
int[] x = {34, 45, 78};
Also look at this:
Declaration with data type
int[] a,b = new int[3]; //multiple arrays declared
Declaration with variable
int a[], b;//multiple declaration, but not all are arrays
a = new int[3];//later you can define the array size