enumerated data types in java
Java
// 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();
}
}
what is enum in 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);
}
}
enum Color { RED, GREEN, BLUE; }
public class Main {
public static void main(String[] args){
Color c1 = Color.GREEN;
System.out.println(c1);
}
}
Also in Java:
- Title
- get preference value android
- Category
- Java
- Title
- java map print
- Category
- Java
- Title
- formatting an integer in java
- Category
- Java
- Title
- jtable font size
- Category
- Java
- Title
- java array copy
- Category
- Java
- Title
- java stack pop
- Category
- Java
- Title
- java remove non numbers from string
- Category
- Java
- Title
- java replace all html tags
- Category
- Java
- Title
- android bottom navigation hiding views
- Category
- Java
- Title
- android round double to 2 decimal
- Category
- Java
- Title
- exponents java
- Category
- Java
- Title
- arraylist array
- Category
- Java
- Title
- nth prime number java
- Category
- Java
- Title
- array in line java
- Category
- Java
- Title
- difference between compile and execute in java
- Category
- Java
- Title
- copy array in java
- Category
- Java
- Title
- how to change actionbar color in android programmatically
- Category
- Java
- Title
- bubble sort in java
- Category
- Java
- Title
- java type casting
- Category
- Java
- Title
- how to find the intersection of two rectangles in java
- Category
- Java
- Title
- logger in java
- Category
- Java
- Title
- java arraylist to string
- Category
- Java
- Title
- string to char in java
- Category
- Java
- Title
- how to import another class in java
- Category
- Java
- Title
- imageview.setbackground
- Category
- Java
- Title
- spring data jpa inheritance repository
- Category
- Java
- Title
- Compare integers java sort
- Category
- Java
- Title
- FileNotFoundException: properties/fortunes.txt (No such file or directory)
- Category
- Java
- Title
- java compareto
- Category
- Java
- Title
- bootstrap button bigger
- Category
- Java
- Title
- faire un timer en java
- Category
- Java
- Title
- how to print each element of an arraylist on a new line in java
- Category
- Java
- Title
- how to write a perfect shuffle method in java
- Category
- Java
- Title
- join two lists java
- Category
- Java
- Title
- java collapse string array
- Category
- Java
- Title
- java split for multiple characters
- Category
- Java
- Title
- how to add objects in array java
- Category
- Java
- Title
- android create snackbar
- Category
- Java
- Title
- hello world java
- Category
- Java
- Title
- how add strings together
- Category
- Java
- Title
- how to change text size of textview with code in android studio
- Category
- Java
- Title
- teimpo en segundos java
- Category
- Java
- Title
- java connect to mysql
- Category
- Java
- Title
- filter and map multiple fields from java stream
- Category
- Java
- Title
- how to add a list in a list java
- Category
- Java
- Title
- linux command to see all the java version installed
- Category
- Java
- Title
- math min max java
- Category
- Java
- Title
- fibonacci sequence java
- Category
- Java
- Title
- how to check the lines in a file java scanner
- Category
- Java
- Title
- java stack push
- Category
- Java
- Title
- Java nested array hashcode
- Category
- Java
- Title
- how to write queries in java
- Category
- Java
- Title
- java time code
- Category
- Java
- Title
- foreach in java
- Category
- Java
- Title
- how to check if in array java
- Category
- Java
- Title
- break for loop java
- Category
- Java
- Title
- arraylist with values java
- Category
- Java
- Title
- validation list empty java
- Category
- Java
- Title
- jbutton open jframe java
- Category
- Java
- Title
- length of string java
- Category
- Java
- Title
- java for in loop
- Category
- Java
- Title
- java comparable
- Category
- Java
- Title
- system.out.println shortcut
- Category
- Java
- Title
- format localdate java
- Category
- Java
- Title
- for loop java
- Category
- Java
- Title
- java convert string to int array
- Category
- Java
- Title
- how to iterate hashmap java
- Category
- Java
- Title
- java string regexp replace
- Category
- Java
- Title
- java io
- Category
- Java
- Title
- arraylist get last
- Category
- Java
- Title
- spigot custom join message
- Category
- Java
- Title
- java fullscreen jframe
- Category
- Java
- Title
- java copy array
- Category
- Java
- Title
- spigot deal damage
- Category
- Java
- Title
- java tester si un caractere est une lettre
- Category
- Java
- Title
- FORM EN JAVA SCRIPT
- Category
- Java
- Title
- javafx polygon
- Category
- Java
- Title
- binary number input in int java
- Category
- Java
- Title
- java check if directory exists
- Category
- Java
- Title
- java integer to binary string
- Category
- Java
- Title
- how to import jframe in java
- Category
- Java
- Title
- java connect mariadb
- Category
- Java
- Title
- main class java
- Category
- Java
- Title
- java int to binary
- Category
- Java
- Title
- check java version cmd
- Category
- Java
- Title
- how to print in java
- Category
- Java
- Title
- get method of a class which I only have string to
- Category
- Java
- Title
- why static variables cannot be serialized in java
- Category
- Java
- Title
- even or odd in java
- Category
- Java
- Title
- dice in java
- Category
- Java
- Title
- difference between java and javascript
- Category
- Java
- Title
- java hello world
- Category
- Java
- Title
- annotation spring notnull
- Category
- Java
- Title
- Kotlin is like java
- Category
- Java
- Title
- get random number from enum in java
- Category
- Java
- Title
- addition of two numbers in java
- Category
- Java
- Title
- how to create an array of arraylist in java
- Category
- Java
- Title
- Android recycleView
- Category
- Java
- Title
- joptionpane.showconfirmdialog yes no example
- Category
- Java
- Title
- java get last char of string
- Category
- Java