CORE API / NOTES</>↗Core API11 May 2007
In the other examples on this website you might have seen how to reverse a string using StringBuffer, StringUtils from Apache Commons Lang library or using the CharacterIterator. In this example you’ll see another way that you can use to reverse a string by word. Here we use the StringTokenizer and the Stack class. package […]
CORE API / NOTES</>↗Core API07 May 2007
Varargs can be seen as a simplification of array when we need to pass a multiple value as a method parameter. Varargs itself is an array that automatically created, for these reason you will be enabled to do things you can do with array to varargs. In the example below you can see the messages […]
CORE API / NOTES</>↗Core API02 May 2007
The trim() method of a String class removes both leading and trailing white space from a string. In this example we use a regular expression to remove only the trailing white spaces from a string. package org.kodejava.lang; public class TrailingSpace { public static void main(String[] args) { String text = " tattarrattat "; System.out.println("Original = […]
CORE API / NOTES</>↗Core API27 Apr 2007
The trim() method of a String class removes both leading and trailing white space from a string. In this example we use a regular expression to remove only the leading white spaces from a string. package org.kodejava.lang; public class LeadingSpace { public static void main(String[] args) { String text = " tattarrattat "; System.out.println("Original = […]
CORE API / NOTES</>↗Core API25 Apr 2007
package org.kodejava.util; import java.util.LinkedList; import java.util.Queue; public class QueueDemo { public static void main(String[] args) { // Create an instance of a queue, ere we use the LinkedList class which // implements the Queue interface. Add some elements to the queue using // the offer method. Queue<String> queue = new LinkedList<>(); queue.offer("First visitor"); queue.offer("Second visitor"); […]
SWING / NOTES</>↗Swing21 Apr 2007
Here you will see how to handle the window closing event of a JFrame. What you need to do is to implement a java.awt.event.WindowListener interface and call the frame addWindowListener() method to add the listener to the frame instance. To handle the closing event implements the windowClosing() method of the interface. Instead of implementing the […]