Lets take this for Example:
public class Vehicle {
public enum Car {
CAR1,
CAR2,
CAR3,
CAR4,
}
public enum BIKE {
BIKE1,
BIKE2,
BIKE3
}
}
public class Main {
public static void main(String args[]) {
Vehicle.Car value1 = Vehicle.Car.CAR1;
Vehicle.Bike value2 = Vehicle.Bike.BIKE1;
print(evaluateType(value1));
// Expected Output: Car
print(evaluateType(value2));
// Expected Output: Bike
}
}
Now the use case here is, We have to write the function evaluateType
. I was wondering if there is a way to know the type of Enum we are using, if it is of type Bike
or Car
.
Given the fact the enums are stored as Int in memory, this doesn't seems like it can be done. But looking forward to any suggestion on how this type of situations could be handled.
Thank you.