declaration of enum in java - the java concepts

Declaration of enum in java:-

(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 ๐Ÿ”—


Comments

Popular posts from this blog

Advantages of Object Oriented Programming - Learn Java - The Java Concepts

Java Naming Conventions - thejavaconceptspart

Advantage and Disadvantages of Top-down Programming - Learn Java - The Java Concepts Part