1package com.tutorialspoint;
2
3import java.lang.*;
4
5// enum showing Mobile prices
6enum Mobile {
7 Samsung(400), Nokia(250),Motorola(325);
8
9 int price;
10 Mobile(int p) {
11 price = p;
12 }
13 int showPrice() {
14 return price;
15 }
16}
17
18public class EnumDemo {
19
20 public static void main(String args[]) {
21
22 System.out.println("CellPhone List:");
23 for(Mobile m : Mobile.values()) {
24 System.out.println(m + " costs " + m.showPrice() + " dollars");
25 }
26
27 Mobile ret = Mobile.Samsung;
28 System.out.println("The ordinal is = " + ret.ordinal());
29 System.out.println("MobileName = " + ret.name());
30 }
31}