BASIC / CATATAN</>↗Basic10 Sep 2008
An inner class is a class defined inside another class. Inner classes can, in fact, be constructed in several contexts. An inner class defined as a member of a class can be instantiated anywhere in that class. An inner class defined inside a method can only be referred to later in the same method. Inner […]
BASIC / CATATAN</>↗Basic06 Sep 2008
To enable our object to be cloned we need to override Object class clone method. We can also add a java.lang.Cloneable interface to our class, this interface is an empty interface. When we call the clone() method we need the add a try-catch block to catch the CloneNotSupportedException. This exception will be thrown if we […]
APACHE COMMONS / CATATAN</>↗Apache Commons01 Sep 2008
package org.kodejava.commons.codec; import org.apache.commons.codec.binary.Base64; import java.util.Arrays; public class Base64Decode { public static void main(String[] args) { String hello = "SGVsbG8gV29ybGQ="; // Decode a previously encoded string using decodeBase64 method and // passing the byte[] of the encoded string. byte[] decoded = Base64.decodeBase64(hello.getBytes()); // Print the decoded array System.out.println(Arrays.toString(decoded)); // Convert the decoded byt...
APACHE COMMONS / CATATAN</>↗Apache Commons28 Agt 2008
package org.kodejava.commons.codec; import org.apache.commons.codec.binary.Base64; import java.util.Arrays; public class Base64Encode { public static void main(String[] args) { String hello = "Hello World"; // The encodeBase64 method take a byte[] as the parameter. The byte[] // can be from a simple string like in this example, or it can be from // an image file data. byte[] […]
CORE API / CATATAN</>↗Core API24 Agt 2008
package org.kodejava.util; import java.util.*; public class SetToArray { public static void main(String[] args) { // Create a java.util.Set object and add some integers into the Set. Set<Integer> numberSet = new HashSet<>(); numberSet.add(1); numberSet.add(2); numberSet.add(3); numberSet.add(5); numberSet.add(8); // Converting a java.util.Set into an array can be done by creating a // java.util.List object from the Set […]
CORE API / CATATAN</>↗Core API23 Agt 2008
The code below gives you an example of converting a java.util.Set into a java.util.List. It has simply done by creating a new instance of List and pass the Set as the argument of the constructor. package org.kodejava.util; import java.util.*; public class SetToList { public static void main(String[] args) { // Create a Set and add […]