Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8975527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:54:20+00:00 2026-06-15T18:54:20+00:00

I have a class from sample project.But when I am using this class it

  • 0

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.)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:54:21+00:00Added an answer on June 15, 2026 at 6:54 pm

    You cannot extend from Enum. You have to declare an Enum class like:

    public enum Q {
        TYPE1, TYPE2, TYPE3;
    }
    

    And you also cannot instantiate an enum class directly. Each type of your enum class is instantiated exactly once by the virtual machine.

    public class MyClass {
    
        public enum MyEnum{
            TYPE1("Name", 9,1,100000), TYPE2("Name2", 10, 1, 200000);
    
            private final int androidVersion;
            private final int appVersionCode;
            private final int availableMemSize;
            private final String appVersionName;
    
            private MyEnum(String appVersionName, int androidVersion, int appVersionCode, int availableMemSize) {
                this.androidVersion = androidVersion;
                this.appVersionCode = appVersionCode;
                this.availableMemSize = availableMemSize;
                this.appVersionName = appVersionName;
            }
        }
        MyEnum mType = MyEnum.TYPE1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this sample code for async operations (copied from the interwebs) public class
I have the following class (from a simple Spring tutorial) public class CarValidator implements
I have a simple class inheriting from WebControl as follow: public class Instrument :
I have an simple class that I get from a webservice. public class person
I have a "simple" 4 class example that reliably shows unexpected behavior from java
the question is simple. I have a base abstract class (person). From this i
I have a class derived from Dictionary. I need this class to simulate a
For a class project I'm trying to do some socket programming Python but running
I have a simple model class (Part), which pulls from it's information from a
I have copied class from net which inherits UIImageView. How to put that class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.