Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-11-2009
Member
 
Join Date: Nov 2009
Posts: 356
Problem in Enum

Hi everyone
I have a problem in my java program. I have posted the code below. See if you can help me out.
Code:
<pre>public class FileSystem {
private Directory _current;
private enum Cmd {
CD {
String execute(String param) {
Directory newDir = _current.getChild(param);
...
}
},
...
;
abstract String execute(String param);
}
...
}</pre>
Thanks in advacne
Reply With Quote
  #2  
Old 18-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Problem in Enum

Hi
I have noticed an error in your example, that is an enum is implicitly static, like an interface. I am posting you an example, just go through it.
Code:
public enum myCars{
    HONDA,BMW,TOYOTA
};
Code:
public class Main {
    public static void main(String[] args) {
        // TODO code application logic here    
        myCars crrcar=myCars.BMW;
        System.out.println("My Current Cars : "+ myCars.BMW);
    }
}
Reply With Quote
  #3  
Old 18-11-2009
Member
 
Join Date: Nov 2009
Posts: 356
Re: Problem in Enum

Thanks for replying
Ok, I forgot to think about that. I take it that this means that if I want to access member variables in my enums, I have to pass "this" in via the constructor.
Code:
Command c = UP(this);
But what if I want to do something like the following
Code:
execute(String command, String argument) {
Command c = Command.valueOf(command);
c.execute(argument);
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem in Enum"
Thread Thread Starter Forum Replies Last Post
What is an ENUM in Networking? LajJlI Networking & Security 7 07-03-2011 03:29 AM
Java - question on enum ISAIAH Software Development 5 02-03-2010 10:50 AM
How to use enum values in VB $tatic Software Development 1 10-08-2009 06:25 PM
How to convert string to enum in vb.net application GunFighter Software Development 3 30-07-2009 01:12 PM
Missing Enum File re HP printer dayleking Hardware Peripherals 4 12-02-2009 06:15 PM


All times are GMT +5.5. The time now is 08:06 AM.