Monday, March 20, 2006

StringTokenizer

tringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead." The following example illustrates how the String.split method can be used to break up a string into its basic tokens:

String[] result = "this is a test".split("\\s");

for (int x=0; x<result.length; x++)

System.out.println(result[x]);

prints the following output: this is a test

caveat emptor!. JDK 1.4.2 fulfilled the promise of core support for regular expressions. However RegEx usage is computationally expensive since regex should be internally compiled before applying it against a target. If you plan to use a lot of RegEx, objectizing them helps reduce the runtime cost, especially when the expressions don't change, and are often reused. Make sure you compile them using the Pattern class.

Wednesday, March 15, 2006

static A a = new A()

A static field exists one per class per class loader.

How can we make system calls in Java

public class Runtime from lang package is used to make system calls

private methods are implictly final

private and final methods are NOT inlined.

Thinking in Java - Online

Friday, March 10, 2006

Regular Expressions

Check these.

see the package java.util.regex and in particular the class java.util.regex.Pattern