CORE API / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 / NOTES</>↗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 […]
CORE API / NOTES</>↗Core API28 Jan 2006
To get the length of a String object we can use the String.length() method. This method returns the string length as an int value. The length of the string is equals to the length of the sequence of characters represented by this string object, and it is equals to the number of 16-bit Unicode characters […]
CORE API / NOTES</>↗Core API25 Jan 2006
To compare strings for their content equality we must use the String.equals() method. This method ensures that it will compare the content of both string instead of the object reference of the both string. This method returns true if both string in comparison have the same content. Do not, never, use the == operator to […]