CORE API / NOTES</>↗Core API05 Apr 2007
package org.kodejava.lang; public class StringReplace { public static void main(String[] args) { String text = "The quick brown fox jumps over the lazy dog"; System.out.println("Before: " + text); // The replace method replace all occurrences of character // 'o' with 'u' and returns a new string object. text = text.replace('o', 'u'); System.out.println("After : " + […]
CORE API / NOTES</>↗Core API03 Apr 2007
package org.kodejava.lang; public class CharArrayCopyExample { public static void main(String[] args) { char[] data = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}; // Copy all value in the char array and create a new string out of it. String text = String.valueOf(data); System.out.println(text); // Copy a sub array from the char array […]
CORE API / NOTES</>↗Core API02 Apr 2007
package org.kodejava.lang; public class TrimStringExample { public static void main(String[] args) { String text = " tattarrattat "; System.out.println("Original = " + text); System.out.println("text.length() = " + text.length()); // The trim() method will result a new string object with a leading and // trailing while space removed. text = text.trim(); System.out.println("Result = " + text); […]
CORE API / NOTES</>↗Core API29 Mar 2007
This example give you an example using java.text.DecimalFormat class to add leading zeros to a number. For another method you can read the see the earlier example on How do I add leading zeros to a number?. package org.kodejava.text; import java.text.DecimalFormat; import java.text.NumberFormat; public class NumberFormatLeadingZerosExample { public static void main(String[] args) { NumberFormat formatter […]
CORE API / NOTES</>↗Core API27 Mar 2007
This example shows you how to use the String.format() method to add zero padding to a number. If you just want to print out the result you can use System.out.format(). This method is available since Java 1.5, so If you use a previous version you can use the NumberFormat class, see: How do I format […]
JDBC / NOTES</>↗JDBC23 Mar 2007
A batch statement can be used to execute multiple update commands as single unit in a database manipulation. This statement in the database is not executed one by one but as a single execution instead. In some cases, using a batch update can be more efficient than to execute the commands separately. In this example, […]