The error is very specific: You cannot assign an ObjectOwner[]
(an array) to a List<ObjectOwner>
(instance of a class that implements List
interface). Instead, you can change your code to adapt this array and convert it into a list using Arrays#asList
:
oo = Arrays.asList(proxy2.getObjectOwner());
Note that by doing this you cannot add new elements in this list. If you want to modify the state of the list, it would be better creating a new ArrayList
(or another desired implementation of List
interface) and add the elements in the array:
//Since Java 7
oo = new ArrayList<>(Arrays.asList(proxy2.getObjectOwner()));
//For Java 5 and 6
oo = new ArrayList<ObjectOwner>(Arrays.asList(proxy2.getObjectOwner()));