I need to declare an enum variable as a class member and need to define a setter and getter for that like a java bean. something like this –
public class Vehicle {
private String id;
private String name;
enum color {
RED, GREEN, ANY;
}
// setter and getters
}
Now, I want to set color property as red, green or any from some other class and want to make decisions accordingly.
The enum will have to be made public to be seen by the outside world:
Then from outside the package you can do:
if you only need to use Vehicle.Color inside the same package as
Vehicleyou may remove thepublicfrom theenumdeclaration.