Tuesday, March 18, 2008

Performance enhancements in Java 5

Followings have been listed on Sun website as improved program execution speed in Java 5

1. Garbage Collection
2. New Class – StringBuilder (Unsynchronized StringBuffer)
3. Java 2D enhancements (in BufferedImage objects)
4. Image I/O enhancements (in JPEG image read, write)

Thursday, March 6, 2008

Java - case insensitive Array sort

java.util.Arrays#sort() is case sensitive.

String[] strArray = new String[]{"a","Z","b"}
//the sorted array will be ={"Z","a","b"}

To get the case insensitive array sort use String.CASE_INSENSITIVE_ORDER

Arrays.sort(strArray, String.CASE_INSENSITIVE_ORDER); //the sorted array will be ={"a","b","Z"}