As per the documentation:
Get all the objects in the world, or all the objects of a particular class.
If a class is specified as a parameter, only objects of that class (or its subclasses) will be returned.
Since you have passed the Class
as Object.class
. It is returning a List
of java.lang.Object
class and hence you get that error .You need to rename your class.
((yourClassName)getObjects(yourClassName.class).get(0)).getPosition();