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

Java & Java Uses - thejavaconceptsparts

Buzzword in Java - thejavaconceptspart

Java Naming Conventions - thejavaconceptspart