can i make my enum private or protected. for ex
enum day{sun,mon,tue};
this is what we usually give. Can i give like
private enum day{mon,..};
can i make my enum private or protected. for ex
enum day{sun,mon,tue};
this is what we usually give. Can i give like
private enum day{mon,..};
Yes, you can put access modifiers in front of enums, just as you can with classes.
This snippet compiles just fine:
class Main {
enum SomePkgEnum { A, B, C };
public enum SomePubEnum { A, B, C };
private enum SomePrivEnum { A, B, C };
protected enum SomeProtEnum { A, B, C };
}
// Top-level enum: Only public (or package level) access allowed.
public enum SomeOtherEnum { A, B, C };