Click here to watch in Youtube :
https://www.youtube.com/watch?v=aEePhT_ZTEA&list=UUhwKlOVR041tngjerWxVccw
EnumDemo.java
https://www.youtube.com/watch?v=aEePhT_ZTEA&list=UUhwKlOVR041tngjerWxVccw
EnumDemo.java
enum Mobile
{
Samsung, Nokia, Motorola;
}
public class EnumDemo
{
public static void main(String args[])
{
Mobile mobile = Mobile.Nokia;
/*
* Returns the ordinal of this enumeration constant
* (its position in its enum declaration, where the
* initial constant is assigned an ordinal of zero).
*/
int ordinal = mobile.ordinal();
System.out.println("The ordinal is = " + ordinal);
}
}
OutputThe ordinal is = 1
Click the below link to download the code:
No comments:
Post a Comment