I am trying to declare an int array in the call of a method, is this possible in Java?
I am relatively new to Java but have some python knowledge. I was trying to find an equivalent of (in python3):
foo([1,2,3,4]) #python
Declaring the array first works ofc:
int[] data = {1,2,3,4,5};
printArray(reverseArray(data));
But I was wondering if something such as:
printArray(reverseArray(int[] {1,2,3,4,5}));
Was possible.
I am working under Netbeans and my above attempted solution is reported as a 'not a statement' error. Also, would:
int[] data = new int[] {1,2,3,4,5}
be more correct than simply:
int[] data = {1,2,3,4,5};
?