Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / August 2005

Tip: Looking for answers? Try searching our database.

nested enum

Thread view: 
a - 30 Aug 2005 02:42 GMT
Is it possible to do a nested enum?
For example,
private enum inside0{a,b,c}
private enum inside1{d,e,f}
private enum outside{inside0, inside1}

outside _variable=outside.inside0.a;    //error here, but want a similar way

Is it possible to set the _variable in the way similar to the above?
Thanx
IchBin - 30 Aug 2005 03:04 GMT
> Is it possible to do a nested enum?
> For example,
[quoted text clipped - 6 lines]
> Is it possible to set the _variable in the way similar to the above?
> Thanx

I do not have the answer but I would recommend you ask this question in
the comp.lang.programmer newsgroup.

Signature

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA  http://weconsultants.servebeer.com
__________________________________________________________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor,  Regular Guy (1952-)

Oliver Wong - 30 Aug 2005 15:39 GMT
> Is it possible to do a nested enum?
> For example,
[quoted text clipped - 6 lines]
>
> Is it possible to set the _variable in the way similar to the above?

   There's a fundamental misunderstanding about enums here. In the above
example, no nesting is occuring. In the outer namespace, you have an enum
called "inside0", and inside the namespace of the enum outside, you have an
instance called "inside0". The code above is similar to this:

public class inside0 {
 public final inside0 a = new inside0();
 public final inside0 b = new inside0();
 public final inside0 c = new inside0();
}

public class inside1 {
 public final inside1 d = new inside1();
 public final inside1 e = new inside1();
 public final inside1 f = new inside1();
}

public class outside {
 public final outside inside0 = new outside();
 public final outside inside1 = new outside();
}

As you can see from this code, you have a class named inside0, and you have
a field named inside0, and they each refer to distinct things.

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.