I've got a constructor like this:
public Cat(String name, String[][] friendsOfFriendsNames){...}
And I would like to create a new Cat
like this:
Cat cat = new Cat("Maurycy", {{"Adam", "Greta"}, {"Jurek", "Tyrmand"}});
However I am getting Syntax error on token(s), misplaced construct(s)
error in Eclipse.
It turns out that I can introduce a new variable like friendsOfFriendsNames
and then pass it to the constructor. Eclipse doesn't raise any error then.
String[][] friendsOfFriendsNames = {{"Adam", "Greta"}, {"Jurek", "Tyrmand"}};
Cat cat = new Cat("Maurycy", friendsOfFriendsNames);
Why is it so? Is it possible to pass {{"Adam", "Greta"}, {"Jurek", "Tyrmand"}}
directly to the constructor? If so, how should I do it?