TAGLIB / NOTES</>↗Taglib17 Aug 2009
The <c:forEach> tag in the core JSTL tag library is a useful tag when we want to iterate over a collection of data such as array. It is commonly used to render a tabular data in our web pages in form of HTML table. In the example below we display a weather data that we […]
BASIC / NOTES</>↗Basic15 Aug 2009
This example demonstrate how to user enum‘s name() method to get enum constant name exactly as declared in the enum declaration. package org.kodejava.basic; enum ProcessStatus { IDLE, RUNNING, FAILED, DONE; @Override public String toString() { return "Process Status: " + this.name(); } } public class EnumNameDemo { public static void main(String[] args) { for (ProcessStatus […]
BASIC / NOTES</>↗Basic12 Aug 2009
In order to use a static member of a class in Java we have to qualify the reference with the class name where they came from. For instance to access the PI and abs() from the Math class we should write: double circle = Math.PI * 10; int absolute = Math.abs(-100); For some time you […]
BASIC / NOTES</>↗Basic07 Aug 2009
This example demonstrate the use of enum ordinal() method to get the ordinal value of an enum constant. package org.kodejava.basic; enum Color { RED, GREEN, BLUE } public class EnumOrdinal { public static void main(String[] args) { // Gets the ordinal of this enumeration constant (its // position in its enum declaration, where the initial […]
BASIC / NOTES</>↗Basic06 Aug 2009
As we know that Java enumeration type is powerful compared to enum implementation in other programming language. Basically enum is class typed, so it can have constructors, methods and fields. In the example below you’ll see how a field is defined in an enumeration type. Because each constant value for the Fruit enum is a […]
BASIC / NOTES</>↗Basic05 Aug 2009
The valueOf() method of an enum type allows you to get an enum constant that the value corresponds to the specified string. Exception will be thrown when we pass a string that not available in the enum. package org.kodejava.basic; public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } package org.kodejava.basic; public class […]