Sorting Custom Types in Java

java-thumbnail

The class java.util.Collections provides many Utility methods for simplifying the most commonly used operations. One of the methods available in that class is sort() which is used for sorting elements. Let us the see how the Collections.sort() method operates on pre-defined data-types as well as user-defined data-types. also read: Java Tutorials Java EE Tutorials Design […]

Conversion between Array and List types

java-thumbnail

In some cases, we may need to convert an array to a list or vice versa. The method asList() is available in the Arrays class, and the toArray() method in list and set classes serve this purpose. also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials The Arrays.asList() method converts […]

Using the Jar Utility

java-thumbnail

Jar stands for Java Archive file and it is used to compress and archive one or more files. It is equivalent to Zip file in Window operating system. A typical jar file contains Java class files in addition to source files as well as resource files, like images and properties. Let us see how to […]

Storing Application Data using Preferences API

java-thumbnail

Applications can now make use of the Java Preferences API for storing and retrieving Application related data. The location where the Data gets stored is implementation specific. Two levels of Preferences come into picture, one is the User Preferences for storing user information and the other is the System Preferences that deals with information common […]

Threads Synchronization

java-thumbnail

Synchronization is done in order to protect a segment of code from being accessed by more than a single Thread at any particular instance of time. In Java, synchronization is achieved with the use of synchronized keyword. Synchronization can be applied to methods as well as to a block of code. also read: Java Tutorials […]

Overriding the toString() method in Object class

java-thumbnail

The toString() method in the Object class is used to display some information regarding any object. If any code needs some information of an object of a class, then it can get it by using this method. The toString() method of an object gets invoked automatically, when an object reference is passed in the System.out.println() […]

Externalizable Interface in Java

java-thumbnail

Serialization is the process of giving persistence storage to Java objects so that they can be restored at a later time. Classes can be made persistent in Java by implementing the Serializable interface. Serializable is a marker interface meaning that it has no methods within it. Any Serializable class can be passed on to ObjectOutputStream.writeObject(object) […]

Using the new Process Builder class

java-thumbnail

We all know how to execute programs from within a Java Application by making use of the Runtime Api. For example, assume that we want to launch the Internet Explorer browser within the Java code. Then the following code snippet will just do that, also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java […]

HashCode and equals methods

java-thumbnail

HashTable, HashMap and HashSet are the Collection classes in java.util package that make use of hashing algorithm to store objects. In all these Collection classes except HashSet, objects are stored as key-value pairs. For the storage and the retrieval of any user-defined objects it is a good practice to override the following methods which is […]