Tip Bank

DevX - Software Development Resource

Misuse of System.exit

The System.exit method forces termination of all threads in the Java virtual machine. This can be drastic. It might, for example, destroy all windows created by the interpreter without giving

DevX - Software Development Resource

How to Prevent a Class From Serialization

The following code prevents classes from serialization: public class MyClass implements Serializable{//you can write your code hereprivate void writeObject(ObjectOutputStream out) throws IOException{ throw new NotSerializableException();}private Object readObject(ObjectInputStream in) throws IOException,ClassNotFoundException{

DevX - Software Development Resource

Examine the Number of Extents in a Table

The amount of time it takes to retrieve data blocks is proportionate to the number of extents in the table. Ideally, a table should have one to three extents. Run

DevX - Software Development Resource

Customizing JFileChooser

The class JFileChooser inside javax.swing.* can be customized to display your own labels using the UIManager.put() method. It is a static method that takes an Object key (Original value) and

DevX - Software Development Resource

Eliminating Duplicate Values

To eliminate duplicate values in a collection, Java provides it own API. HashSet (java.util.*) is the class which implements Set interface. import java.util.*;class Duplicate{ static void main(String[]arr){ HashSet set=new HashSet();

DevX - Software Development Resource

“Shrink” the Size of a File

Visual Basic lacks the ability to make a file smaller without having to recreate it. But it is possible to use the SetEndOfFile API. Here is a function for it: