declaration of enum in java - the java concepts
(1) Enums declaration can be done outside a class not inside a method.
-----------------------------------------
πClick hereπ
------------------------------------------
(2) The first line inside the enum should be a list of constants and then other things like methods, variables and constructors
(3) According to Java naming convention, it is recommended that we name constant with all capital letters.
Example:—
enum Color
{
RED, GREEN, BLUE;
}
public class Test
{
//Driver methods
public static void main (String[ ]args)
}
Color c1=Color.RED;
System.out.println(c1) ;
}
}
Output:—
RED
------------------------------------------
Related Link'sπ
Important points of enum
-------------------------------------------
Others Related Link π
Introduction Structured Vs Object Oriented Programming
Top-Down and Bottom-up Approaches
Advantages of top-down programming
Disadvantages of top-down programming
Why Object Oriented Approach and Features of object oriented programming ?
Comments
Post a Comment
Remember to keep Comments Respectfully