I have the following class:
private class Info{
public String A;
public int B;
Info(){};
public OtherMethod(){};
private PrivMethod(){};
}
And I want to create an array of this class, but I want to provide a two dimensional array as an argument to the constructor, ie:
Info[] I = new Info({{"StringA", 1}, {"StringB", 2}, {"StringC", 3}});
Is that possible? If so how would I implement it? If not, what alternatives would you suggest?
Its possible, but not using the syntax you suggested. Java doesn’t support creating arrays out of constructors. Try the following: