devxlogo

Tip Bank

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{

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

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

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();

“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: