SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

BASIC / NOTES</>↗
Basic04 Aug 2009

How do I get constants name of an enum?

To get the constants name of an enumeration you can use the values() method of the enumeration type. This method return an array that contains a list of enumeration constants. package org.kodejava.basic; public enum Month { JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER } package org.kodejava.basic; public class EnumValuesTest { […]

Wayan · 1 min read
BASIC / NOTES</>↗
Basic04 Aug 2009

How do I define constructor in enum type?

In the following example you’ll see how to add a constructor to an enum type value. Because an enum is just another class type it can have constructors, fields and methods just like any other classes. Below we define a constructor that accept a string value of color code. Because our enum now have a […]

Wayan · 2 min read
BASIC / NOTES</>↗
Basic04 Aug 2009

How do I use enum in switch statement?

This example show you how to use enumeration or enum type in a switch statement. package org.kodejava.basic; public enum RainbowColor { RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET } package org.kodejava.basic; public class EnumSwitch { public static void main(String[] args) { RainbowColor color = RainbowColor.INDIGO; EnumSwitch es = new EnumSwitch(); String colorCode = es.getColorCode(color); System.out.println("ColorCode […]

Wayan · 1 min read
BASIC / NOTES</>↗
Basic01 Aug 2009

How do I create enumerations type?

Enumeration is a list of named constants. Every most commonly used programming languages support this feature. But in Java it is officially supported since version 5.0. In Java programming language an enumeration defines a class type. Because an enumeration is a class it can have a constructors, methods, and instance variables. To create an enumeration […]

Wayan · 2 min read
SCRIPTING / NOTES</>↗
Scripting31 Jul 2009

How do I import Java package in script?

Here you can see how to import a Java class so that you can use the class, creates an instance of it in the scripting environment. We want to print out the current date on the console. For this we need to import the Date class that’s packaged under the java.util package. In the script […]

Wayan · 2 min read
SCRIPTING / NOTES</>↗
Scripting28 Jul 2009

How do I modify Java object in script?

This example show how to modify Java object from scripting environment. Below we manipulate a collection of string data. To pass data into the scripting engine we use a key-value binding to the script engine. package org.kodejava.script; import javax.script.Bindings; import javax.script.ScriptContext; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; import java.util.List; import java.util.ArrayList; public class M...

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.