i have to create an enum that contains values that are having spaces
public enum MyEnum
{
My cart,
Selected items,
Bi
I agree the use of DisplayText if you are following convention. But if you need different display value to represent the enum constant, then you could have a constructor passing that value.
public enum MyEnum { My cart ("Cart"), Selected items("All Selected Items"), Bill("Payment");
private String displayValue;
private MyEnum(String displayValue) {
this.displayValue = displayValue;
}
public String displayText() {
return this.displayValue;
}
}
You can have a displayText method or a toString method which would return the displayValue