Source Code : Use an enum constructor.

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Use an enum constructor.

  

enum Apple { 
  A(10), B(9), C, D(15), E(8); 
 
  private int price; // price of each apple 
 
  // Constructor 
  Apple(int p) { price = p; } 
 
  // Overloaded constructor 
  Apple() { price = -1; } 
 
  int getPrice() { return price; } 
}


           
         
    
  

Thank with us