I have a function which return a type int. However, I only have a value of the TAX enumeration.
How can I cast the TAX enumeration value to an int?
public enum TAX {
NOTAX(0),SALESTAX(10),IMPORTEDTAX(5);
private int value;
private TAX(int value){
this.value = value;
}
}
TAX var = TAX.NOTAX; // This value will differ
public int getTaxValue()
{
// what do do here?
// return (int)var;
}
Sometime some C# approach makes the life easier in Java world..: