How do you get the class of an abstract class (Object) in JavaME?

advertisements

I need to get the Class of an object at runtime.

For an non-abstract class I could do something like:

public class MyNoneAbstract{
    public static Class MYNONEABSTRACT_CLASS = new MyNoneAbstract().getClass();

But for an abstract class this does NOT work (always gives me Object)

public abstract class MyAbstract{
    public static Class MYABSTRACT_CLASS = MyAbstract.class.getClass();

This code will be running in JavaME environments.


You just need

MyAbstract.class

That expression returns the Class object representing MyAbstract.