Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Enum in Eclipse Scrapbook
Enum in Eclipse Scrapbook [message #1014954] Tue, 26 February 2013 22:45 Go to next message
Robert Mark Bram is currently offline Robert Mark Bram
Messages: 22
Registered: July 2009
Junior Member
Not sure if this is a bug or if I am going a bit crazy.. Am trying to do some quick testing of enums in an Eclipse jpage Scrapbook (using JDK 1.7.0_02, Win XP 64-bit, Eclipse Juno)

class A {
    enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
}
A a = new A();


When I try execute this I get:

Quote:
The member enum Month can only be defined inside a top-level class or interface


And this is what happens if I move the enum out of the class definition.

enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
Month.valueOf("JAN");


These are the errors I got for the above:

Quote:
The member enum Month can only be defined inside a top-level class or interface

Month cannot be resolved
Re: Enum in Eclipse Scrapbook [message #1014991 is a reply to message #1014954] Wed, 27 February 2013 07:27 Go to previous message
Robert Mark Bram is currently offline Robert Mark Bram
Messages: 22
Registered: July 2009
Junior Member
I believe the only way to do this is to move the enum itself out of the jpage into a new class. So I make the class like so:

package test;
public class Test {
   public enum Month {
      JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC;
   };
}


Then in the jpage:


  1. right click and select "Set Imports"
  2. click "Add Packages" and enter/select the test package.


Then my jpage will have the following code only:

Test.Month.valueOf("JAN");
Previous Topic:How do I open an editor programmatically in Eclipse Helios
Next Topic:Retarget Debug actions are not enabled on editor page change
Goto Forum:
  


Current Time: Thu Oct 23 09:01:41 GMT 2014

Powered by FUDForum. Page generated in 0.01500 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software