Link to home
Start Free TrialLog in
Avatar of jdav3579
jdav3579

asked on

pass array as literal to method

Hi,
I have a constructor which accepts an array as an argument.
I want to create a new instance of the object and pass it some literal values for the array, but I cant seem to find the correct syntax for this. Can anyone help?
As an example:
private static int [] DOB = new int[2];
public Object(String name, int [] DOB)
       {
      etc..
       }

Object person= new Object("Bart", {12,05});
So this would create a new object whose name is bart and date of birth 12th of May.
Unfortunately this wouldnt compile as I could not pass the array like this.

Cheers
John
ASKER CERTIFIED SOLUTION
Avatar of imladris
imladris
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did that help?

If so it is now time to grade the answer.

If not, perhaps a clarifying question would help.
Avatar of jdav3579
jdav3579

ASKER

Hi imladris,
I have only just had a chance to try it - but yes it did help thanks.
John