That’s how you can use enumerations for string values:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| /*
* ISO 3166
*/
public enum Country
{
DE
{
@Override
public String toString()
{
return "Germany";
}
},
IT
{
@Override
public String toString()
{
return "Italy";
}
},
US
{
@Override
public String toString()
{
return "United States";
}
}
} |
/*
* ISO 3166
*/
public enum Country
{
DE
{
@Override
public String toString()
{
return "Germany";
}
},
IT
{
@Override
public String toString()
{
return "Italy";
}
},
US
{
@Override
public String toString()
{
return "United States";
}
}
}
1
2
3
4
5
6
| public static void main(String[] args)
{
System.out.println(Country.DE); // Germany
System.out.println(Country.IT); // Italy
System.out.println(Country.US); // United States
} |
public static void main(String[] args)
{
System.out.println(Country.DE); // Germany
System.out.println(Country.IT); // Italy
System.out.println(Country.US); // United States
}