Click to See Complete Forum and Search --> : what is the difference between c++ enum and java?


systematic
May 28th, 2007, 02:43 PM
hi ,


I'm java developer

in java it is Objects instead of integer constants .

I want to ask this question

What is the fundamental difference between the two ?

IllegalCharacter
May 28th, 2007, 09:49 PM
In C/C++, enums are more or less integers (that's the way they are handled under the hood). You can't give your enum methods or anything like that, basically you only capable of making variables of the type and giving them the values you list.

In Java, your enums can have methods attached, so if you have:

enum bla{
BLA1, BLA2, BLA3;

public void doStuff(){
// stuff
}
}

BLA1.doStuff();


It's a bit more complex than this, but that's the jist of it. You can read about it on Sun's site here: http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html.

systematic
May 29th, 2007, 03:59 PM
thanks, IllegalCharacter

that's was very helpful.