Here is a brief code snippet:
someMethod ClassA getClassA() {
List<ClassA.ClassB> classAType = Lists.newArrayList();
//Now classAType is loaded with stuff here
return ClassA.load(classAType.toArray(new ClassA.ClassB[classAType.size()]));
}
public abstract class ClassA {
//Constructor
public static abstract class ClassB {
//some method
}
}
The part which I don’t understand is the return statement.I wanted to know what does ClassA.ClassB[classAType.size()] imply
The
getClassA()method first creates a list withClassA.ClassBobjects returned byLists.newArrayList(). Then, it returnsClassAby calling a static methodClassA.load()passing one parameter: an empty array of typeClassA.ClassBwith the same size as theclassAType.This piece of code:
may look a bit complicated but it just creates an array containing all elements from the
classATypelist.