I have a class and in this class I have this:
//some code private int[] data = new int[3]; //some code
Then in my constructor:
public Date(){ data[0] = 0; data[1] = 0; data[2] = 0; }
If I do, everything will be all right. The default values ββare initialized, but if I do this instead:
public Date(){ int[] data = {0,0,0}; }
It says:
Local variable hides a field
Why?
What is the best way to initialize an array inside a constructor?
thank
java
Favolas Nov 09 '11 at 16:50 2011-11-09 16:50
source share