I want to create an object from my class. My class has an array attribute, how do I pass it through the parenthesis?
This is my class:
private String Description;
private int[] Data = {0, 0, 0, 0, 0, 0, 0, 0, 0};
public Key(String Desc, int[] d)
{
Description = Desc;
Data = d;
}
And this is how I create the object:
Key k1 = new Key("Shoham's Key", {0, 5 , 6, 4, 3, 2, 7, 1, 9});
Thanks.
Note:
new int[] {0, 5 , 6, 4, 3, 2, 7, 1, 9}declaration is called Anonymous Array declaration.