REGEX / CATATAN</>↗Regex17 Des 2007
In this example you’ll see how we can create a small search and replace program using the regular expression classes in Java. The code below will replace all the brown words to red. package org.kodejava.regex; import java.util.regex.Pattern; import java.util.regex.Matcher; public class StringReplace { public static void main(String[] args) { String source = "The quick brown […]
REGEX / CATATAN</>↗Regex14 Des 2007
This example demonstrates how we do regular expression in Java. The regular expression classes is in the java.uti.regex package. The main class including the java.util.regex.Pattern class and the java.util.regex.Matcher class. In this example we are only testing to match a string literal if it is exists in the following sentence, we are searching the word […]
BASIC / CATATAN</>↗Basic10 Des 2007
Here are the summary of the available keywords in the Java programming language. Keywords are reserved words that already taken and internally used by Java, so we cannot create variables and name it using this keyword. Keyword Meaning abstract an abstract class or method assert used to locate internal program errors boolean the Boolean type […]
JDOM / CATATAN</>↗JDOM06 Des 2007
This example provide a small code snippet on how to use JDOM to parse an XML document, iterates each of the element and read the element or attributes values. To play with this example you have to have the JDOM library. You can download it from JDOM website. package org.kodejava.jdom; import org.jdom2.Document; import org.jdom2.Element; import […]
CORE API / CATATAN</>↗Core API02 Des 2007
This example shows you how we can sort items of an ArrayList using the Collections.sort() method. Beside accepting the list object to be sorted we can also pass a Comparator implementation to define the sorting behaviour such as sorting in descending or ascending order. package org.kodejava.util; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public […]
CORE API / CATATAN</>↗Core API28 Nov 2007
By default, when sorting an arrays the value will be ordered in case-sensitive order. This example show you how to order it in case-insensitive order. package org.kodejava.util; import java.util.Arrays; public class SortArrayCaseSensitivity { public static void main(String[] args) { String[] teams = new String[5]; teams[0] = "Manchester United"; teams[1] = "chelsea"; teams[2] = "Arsenal"; teams[3] […]