enum in java
Java
// A simple enum example where enum is declared
// outside any class (Note enum keyword instead of
// class keyword)
enum Color
{
RED, GREEN, BLUE;
}
public class Test
{
// Driver method
public static void main(String[] args)
{
Color c1 = Color.RED;
System.out.println(c1);
}
}
public class MyClass {
enum Level {
LOW,
MEDIUM,
HIGH
}
public static void main(String[] args) {
Level myVar = Level.MEDIUM;
System.out.println(myVar);
}
}
// Java program to demonstrate that enums can have constructor
// and concrete methods.
// An enum (Note enum keyword inplace of class keyword)
enum Color
{
RED, GREEN, BLUE;
// enum constructor called separately for each
// constant
private Color()
{
System.out.println("Constructor called for : " +
this.toString());
}
public void colorInfo()
{
System.out.println("Universal Color");
}
}
public class Test
{
// Driver method
public static void main(String[] args)
{
Color c1 = Color.RED;
System.out.println(c1);
c1.colorInfo();
}
}
Also in Java:
- Title
- are inner classes inherited
- Category
- Java
- Title
- calculating the percentile in java
- Category
- Java
- Title
- java get first char
- Category
- Java
- Title
- array methods in java
- Category
- Java
- Title
- Scanner library showing element not found exception
- Category
- Java
- Title
- java random boolean
- Category
- Java
- Title
- convert every character in string to arraylist jva
- Category
- Java
- Title
- java remove duplicates
- Category
- Java
- Title
- java taking console input
- Category
- Java
- Title
- find the triplet sum in java linked list
- Category
- Java
- Title
- how to add an item to a list in python
- Category
- Java
- Title
- butterfly pattern program in java
- Category
- Java
- Title
- how to skip a line in java
- Category
- Java
- Title
- java null pointer exception
- Category
- Java
- Title
- java call another constructor
- Category
- Java
- Title
- java valeur absolue
- Category
- Java
- Title
- big integer java
- Category
- Java
- Title
- pascal's triangle java 2d array
- Category
- Java
- Title
- java bigdecimal compareto
- Category
- Java
- Title
- java best way to concatenate strings
- Category
- Java
- Title
- parseints(str) java
- Category
- Java
- Title
- java observable to observer
- Category
- Java
- Title
- how to remove all components from layeredPane java
- Category
- Java
- Title
- convert array of int to arraylist java
- Category
- Java
- Title
- Java.awt graphics tutorial
- Category
- Java
- Title
- string reverse in java
- Category
- Java
- Title
- java initialize string array
- Category
- Java
- Title
- org.springframework.orm.jpa.EntityManagerHolder cannot be cast to org.springframework.orm.hibernate5.SessionHolder
- Category
- Java
- Title
- java function that returns the index of the largest value in an array
- Category
- Java
- Title
- java stream sort Collator
- Category
- Java
- Title
- how to split a string in java
- Category
- Java
- Title
- string to int java
- Category
- Java
- Title
- java regex replace all characters before
- Category
- Java
- Title
- java replace element in list
- Category
- Java
- Title
- what is a variable in java
- Category
- Java
- Title
- java create file with content
- Category
- Java
- Title
- capitalize string java
- Category
- Java
- Title
- java map foreach
- Category
- Java
- Title
- difference between compile and execute in java
- Category
- Java
- Title
- how to replace all of one character with nothing in java
- Category
- Java
- Title
- how to print a 2d array in java
- Category
- Java
- Title
- how do I change the opacity of a JButton
- Category
- Java
- Title
- how to remove all whitespace from string java
- Category
- Java
- Title
- query java persistence
- Category
- Java
- Title
- IN APPLet how to disable a button in java
- Category
- Java
- Title
- java bubble sort short circuit
- Category
- Java
- Title
- android elevation not working
- Category
- Java
- Title
- funzione random in java
- Category
- Java
- Title
- java arraylist to string
- Category
- Java
- Title
- login and logout react native and firebase
- Category
- Java
- Title
- selection sort in java
- Category
- Java
- Title
- islowercase java
- Category
- Java
- Title
- reading string after double in java
- Category
- Java
- Title
- android get last crash adb
- Category
- Java
- Title
- generate a qr code in java
- Category
- Java
- Title
- java type casting
- Category
- Java
- Title
- NumSelfDivisors java
- Category
- Java
- Title
- Could not resolve project :app
- Category
- Java
- Title
- entre clavier java
- Category
- Java
- Title
- how to add jar in maven java application in netbeans
- Category
- Java
- Title
- java math.random
- Category
- Java
- Title
- scanner check if int
- Category
- Java
- Title
- java making a screen
- Category
- Java
- Title
- action on long press of edit edittext
- Category
- Java
- Title
- java connect mariadb
- Category
- Java
- Title
- java remove first character from string
- Category
- Java
- Title
- how to make a button disapear on click in javafx
- Category
- Java
- Title
- vector in java
- Category
- Java
- Title
- decomposer chaine de caractère java
- Category
- Java
- Title
- waht does&& mean in java
- Category
- Java
- Title
- get long from date java
- Category
- Java
- Title
- java set to list
- Category
- Java
- Title
- double to string java
- Category
- Java
- Title
- how to check type of primitive value in java
- Category
- Java
- Title
- java hashmap set value
- Category
- Java
- Title
- abstraction in java
- Category
- Java
- Title
- transition java fx
- Category
- Java
- Title
- how to take space separated input in java
- Category
- Java
- Title
- Java script code for add
- Category
- Java
- Title
- count word in string no matter the delimiter java
- Category
- Java
- Title
- android switch on change
- Category
- Java
- Title
- java set example
- Category
- Java
- Title
- get first 5 characters of string java
- Category
- Java
- Title
- java read from connection even if 404
- Category
- Java
- Title
- Android recycleView
- Category
- Java
- Title
- remove extra blank spaces from string in java
- Category
- Java
- Title
- string to double java
- Category
- Java
- Title
- Primitive Type vs. Reference Type
- Category
- Java
- Title
- JOptionPane with drop down list java
- Category
- Java
- Title
- long input in JAVA
- Category
- Java
- Title
- check if a list contains a string java
- Category
- Java
- Title
- http client java
- Category
- Java
- Title
- convert string to mayus java
- Category
- Java
- Title
- java random char a-z
- Category
- Java
- Title
- java nextpermutation
- Category
- Java
- Title
- how to draw a line in java
- Category
- Java
- Title
- open an existing excel file in java apache poi
- Category
- Java
- Title
- java remove non numbers from string
- Category
- Java
- Title
- actionListener java
- Category
- Java
- Title
- arraylist of double
- Category
- Java