I have a class from sample project.But when I am using this class it shows some errors.The class is given below.
public class q extends Enum
{
private int i = -1;
private String s = null;
private q(String s, int i)
{
// super(s, i);
this.s = s;
this.i = i;
}
public static q valueOf(String s)
{
return (q)Enum.valueOf(q.class, s);
}
public static q[] values()
{
return (q[])a.clone();
}
public static final q ANDROID_VERSION;
public static final q APP_VERSION_CODE;
public static final q APP_VERSION_NAME;
public static final q AVAILABLE_MEM_SIZE;
private static final q a[];
static
{
APP_VERSION_CODE = new q("APP_VERSION_CODE", 1);
APP_VERSION_NAME = new q("APP_VERSION_NAME", 2);
ANDROID_VERSION = new q("ANDROID_VERSION", 6);
AVAILABLE_MEM_SIZE = new q("AVAILABLE_MEM_SIZE", 11);
q aq[] = new q[34];
aq[0] = APP_VERSION_CODE;
aq[1] = ANDROID_VERSION;
aq[2] = APP_VERSION_NAME;
aq[3] = AVAILABLE_MEM_SIZE;
a = aq;
}
}
When extending Enum it shows “The type q may not subclass Enum explicitly” error.How can i create an enum using these fields?
How can i modify this class to use like enum(ie,I want to use the default enum methods like ordinal(),valueOf(…) etc.. on this.)?
You cannot extend from
Enum. You have to declare anEnumclass like:And you also cannot instantiate an enum class directly. Each type of your enum class is instantiated exactly once by the virtual machine.