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 7033595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:05:05+00:00 2026-05-28T01:05:05+00:00

I am developing for mobile on Java 1.3 and don’t have enum type, so

  • 0

I am developing for mobile on Java 1.3 and don’t have enum type, so instead am using the Typesafe Enum Pattern. E.g.

public class DownloadEvent {

    //Download events
    public static final DownloadEvent DOWNLOAD_STARTED = new DownloadEvent("Download started");
    public static final DownloadEvent DOWNLOAD_COMPLETED = new DownloadEvent("Download completed");

    private String eventDescription;

    private DownloadEvent(String eventDescription){

        this.eventDescription = eventDescription;
    }

    public String toString(){
        return eventDescription;
    }
} 

The problem with this approach is that the compiler won’t allow classes inside switch statements e.g.

DownloadEvent event = getDownloadEvent(); //returns a download event

switch(event){
case DownloadEvent.DOWNLOAD_STARTED:
    //do some stuff
}

Is there any way around this? Or should I go back to using lists of int constants

  • 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-05-28T01:05:06+00:00Added an answer on May 28, 2026 at 1:05 am

    You could give the DownloadEvent a type-property (for example an int) which you can retrieve with a getter, and use that property in your switch statement

    DownloadEvent event = getDownloadEvent(); //returns a download event
    
    switch(event.getType() ){
    case DownloadEvent.DOWNLOAD_STARTED.getType():
        //do some stuff
    }
    

    But this is of course not as-nice as using an enum

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a mobile site using jQuery mobile. I have one simple
I'm developing a mobile site for iPhone using jQuery. I have a hidden div
I am working on developing a mobile application using java for messaging services(P2P) I
I am developing a mobile app to run on a pocketpc. We have a
I'm developing a mobile site using IUI . It's a framework that makes web
I am developing a study project using the mosembro (mobile semantic browser) project inside
I'm developing a mobile site using Zend framework, and the site has two possible
I am developing a java mobile application. Its purpose is that, when installed, it
I am developing an application in java for a mobile platform. The program uses
I have been developing server side applications in java, and now I have been

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.