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.

SCRIPTING / NOTES</>↗
Scripting18 Jul 2009

How do I evaluate a simple script?

The code below will evaluate a simple JavaScript that produces a “Hello World” message. To evaluate the script, the ScriptEngine provides us with some overloaded eval() methods, for instance an eval() methods that accept the script in string or in Reader object. package org.kodejava.script; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; import javax.script.ScriptException; public class EvaluatingScript { public […]

Wayan · 1 min read
SCRIPTING / NOTES</>↗
Scripting14 Jul 2009

How do I create an instance of ScriptEngine class for JavaScript?

This example demonstrates how to create a JavaScript interpreter or the ScriptEngine to run JavaScript in Java. The classes related to scripting is packaged under the javax.script.* package. In this example we show you how to create the JavaScript engine by using the engine extension. package org.kodejava.script; import javax.script.ScriptEngineManager; import javax.script.ScriptEngine; public class GettingJavaScriptEngine { […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API12 Jul 2009

How do I get the last element of SortedSet?

package org.kodejava.util; import java.util.SortedSet; import java.util.TreeSet; public class LastSetElement { public static void main(String[] args) { SortedSet<String> numbers = new TreeSet<>(); numbers.add("One"); numbers.add("Two"); numbers.add("Three"); numbers.add("Four"); numbers.add("Five"); // SortedSet orders the items it contains. We can get the last // item from the set using the last() method. The last item // will be "Two". String […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API09 Jul 2009

How do I get the first element of SortedSet?

package org.kodejava.util; import java.util.TreeSet; import java.util.SortedSet; public class FirstSetElement { public static void main(String[] args) { SortedSet<String> numbers = new TreeSet<>(); numbers.add("One"); numbers.add("Two"); numbers.add("Three"); numbers.add("Four"); numbers.add("Five"); // SortedSet orders the items it contains. We can get the first // item from the SortedSet using the first() method. The fist item // will be "Five". String […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API06 Jul 2009

How do I get all annotations?

To obtains all annotations for classes, methods, constructors, or fields we use the getAnnotations()method. This method returns an array of Annotation In the following example we tried to read all annotations from the sayHi() method. First we need to obtain the method object itself. Because the sayHi() method has parameters, we need to pass not […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API05 Jul 2009

How do I obtain annotations at runtime using reflection?

This example demonstrate how to obtain annotations of a class and methods. We use the reflection API to get class and method information from where we can read information about annotation attached to the class or the method. package org.kodejava.lang.annotation; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @HelloAnnotation(value = "Hello", greetTo = "Universe") public class GettingAnnotation { public […]

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.