I just would like to extract the “name” attribute of my structure into a string[].
I know there must be a smart solution – but I don’t have an idea what to look for.
List<MyStruct> myStruct1;
public class MyStruct1 {
public String name1;
public List<MyStruct2> myStruct2;
}
public class MyStruct2 {
public String name2;
public List<MyStruct3> myStruct3;
}
and what I am looking for is
String[] names1 = ? the array of all name1 coming from MyStruct1 ?
I know the .toArray conversion for simple lists, but I don’t have an idea how to get it from inside a structure. I would think there is a solution WITHOUT having to loop manually.
Many thanks!
Maybe I am overlooking something, but:
Or, are MyStruct1 and MyStruct2 subclasses of MyStruct and you only want the names from MyStruct2 objects?