CORE API / CATATAN</>↗Core API12 Feb 2006
There are times when we want to convert data from primitive data types into a string, for instance when we want to format output on the screen or simply mixing it with other string. Using a various static method String.valueOf() we can get a string value of them. Here is the code sample: package org.kodejava.lang; […]
CORE API / CATATAN</>↗Core API11 Feb 2006
This example shows you how to create a repeated sequence of characters. To do this, we use the Arrays.fill() method. This method fills an array of char with a character. package org.kodejava.util; import java.util.Arrays; public class RepeatCharacterExample { public static void main(String[] args) { char c = '*'; int length = 10; // creates a […]
CORE API / CATATAN</>↗Core API07 Feb 2006
The code below is an example of using StringTokenizer to split a string. In the current JDK this class is discouraged to be used, use the String.split(…) method instead or using the new java.util.regex package. package org.kodejava.util; import java.util.StringTokenizer; public class StringTokenizerExample { public static void main(String[] args) { StringTokenizer st = new StringTokenizer("A StringTokenizer […]
CORE API / CATATAN</>↗Core API06 Feb 2006
To test if a string starts with a specific prefix we can use the String.startsWith(String prefix) method. This method returns a boolean true as the result if the string starts with that specified prefix. The String.startsWith() method checks the prefix in case-sensitive manner. The following code snippet give us a small example how to use […]
CORE API / CATATAN</>↗Core API02 Feb 2006
The String.endsWith() method can be used to check if a string ends with a specific word. It will return a boolean true if the suffix is found at the end of the string object. In this example we will start the code by creating a class called StringEndsWithExample. This class has a standard main() method […]
CREATIONAL PATTERNS / CATATAN</>↗Creational Patterns31 Jan 2006
Singleton Pattern is used when we want to allow only a single instance of a class can be created inside our application. This pattern ensures that a class only have a single instance by protecting the class creation process, which can be done by defining the class constructor with private access modifier. To get an […]