Hi,
I'm a total beginner with Java - coming from C++
In the code snippet below, I want to protect the parameter 'V" in method display
from beeing modified. How can this be achieved (the attribute 'final" doesn't seem to work).
Many thanks for a hint,
Helmut.
class Test {
public static void main(String[] args) {
int[] A = new int[3];
for (int i=0; i < A.length;i++) A[i]= 7*i;
display(A);
System.out.println(A[0]);
}
static void display( final int[] V) {
V[0]=17; // WHY NO ERROR here <========================== ?
for (int i=0; i < V.length;i++)
System.out.println(i+" "+V[i]);
}
}