-
Constructor with enum
I have the following class:
Code:
public class GTent{
enum ttype{RANGE,LENGTH};
int length;
ttype blockType;
public GTent(int i, int j, ttype t) {
this.length= i + j;
this.blockType = t;
}
In some other class, I want to create an object of it. I am not sure how to supply enum value to the constructor. Please advice.
-
enum and constructors
Hello bugger.
Add the public modifier to the definition of your enumerator. Then use the name of your class as you would when you access static members:
Code:
GTent test = new GTent(0, 0, GTent.ttype.RANGE);
Hope this helped. ;)
-
Thanks tim. It worked. I simply imported the enumeration using public modifier.
Keep posting mate.