I have enum like below
enum Car {
lamborghini("900"),tata("2"),audi("50"),fiat("15"),honda("12");
private String price;
Car(String p) {
price = p;
}
String getPrice() {
return price;
}
}
public class Main {
public static void main(String args[]){
System.out.println("All car prices:");
System.out.println(Car.valueOf("lamborghini").getPrice());
for (Car c : Car.values())
System.out.println(c + " costs "
+ c.getPrice() + " thousand dollars.");
}
}
This is working fine,But I have Input like "900" ,So I want to get that enumConstructorName like lamborghini ,How can I do this.