Java Tutorials

191. store() and load() example in Java

By: Kamini : 2007-09-14

Description: One of the most useful aspects of Properties is that the information contained in a Properties object can be easily stored to or loaded from disk with the store() and load() methods. At any time, you can write a Properties object to a stream or read it back. This makes property lists especially convenient for implementing simple databases.


192. insert() and reverse() in Java

By: Henry : 2007-09-12

Description: The insert() method inserts one string into another. It is overloaded to accept values of all the simple types, plus Strings and Objects. Like append(), it calls String.valueOf() to obtain the string representation of the value it is called with. This string is then inserted into the invoking StringBuffer object. These are a few of its forms:


193. HashSet Sample program in Java

By: Kamini : 2007-09-12

Description: HashSet extends AbstractSet and implements the Set interface. It creates a collection that uses a hash table for storage. As most readers likely know, a hash table stores information by using a mechanism called hashing. In hashing, the informational content of a key is used to determine a unique value, called its hash code. The hash code is then used as the index at which the data associated with the key is stored. The transformation of the key into its hash code is performed automatically-you never see the hash code itself. Also, your code can't directly index the hash table. The advantage of hashing is that it allows the execution time of basic operations, such as add(), contains(), remove(), and size(), to remain constant even for large sets.


194. LinkedList Sample program in Java

By: Jagan : 2007-09-12

Description: The LinkedList class extends AbstractSequentialList and implements the List interface. It provides a linked-list data structure. It has the two constructors, shown here:


195. toRadians() and toDegrees() Sample program in Java

By: Ivan Lim : 2007-09-12

Description: The toRadians() method converts degrees to radians. toDegrees() converts radians to degrees. Here is a program that demonstrates toRadians() and toDegrees():


196. getClass() and getSuperclass() in Java

By: Ivan Lim : 2007-09-12

Description: The following program demonstrates getClass() (inherited from Object) and getSuperclass() (from Class):


197. clone() and the Cloneable Interface in Java

By: Henry : 2007-09-12

Description: Most of the methods defined by Object are discussed elsewhere in this book. However, one deserves special attention: clone(). The clone() method generates a duplicate copy of the object on which it is called. Only classes that implement the Cloneable interface can be cloned.


198. arraycopy() in Java

By: Jagan : 2007-09-12

Description: The arraycopy() method can be used to copy quickly an array of any type from one place to another. This is much faster than the equivalent loop written out longhand in Java. Here is an example of two arrays being copied by the arraycopy() method. First, a is copied to b. Next, all of a's elements are shifted down by one. Then, b is shifted up by one.


199. delete() and deleteCharAt() in Java

By: Ivan Lim : 2007-09-12

Description: Java 2 adds to StringBuffer the ability to delete characters using the methods delete()


200. append() in Java

By: Jagan : 2007-09-12

Description: The append() method concatenates the string representation of any other type of data to the end of the invoking StringBuffer object. It has overloaded versions for all the built-in types and for Object. Here are a few of its forms: