Collection Framework in Java

Collection Framework in Java,The Java collections framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures.

Generics Hashtable

Three programs are given on Hashtable. Hashtable General: Uses the methods like elements, containsKey, put, get, contains and keys. Hashtable Generics: Creates generics Hashtable storing strings and integers and uses the methods like keySet, values, hashCode, putAll, clear, size, iterator, remove and isempty etc. Hashtable Special: Uses the methods like clone(), hashCode() and the values …

Generics Hashtable Read More »

Hashtable Hash Code Example

Three programs are given on Hashtable. Hashtable General: Uses the methods like elements, containsKey, put, get, contains and keys. Hashtable Generics: Creates generics Hashtable storing strings and integers and uses the methods like keySet, values, hashCode, putAll, clear, size, iterator, remove and isempty etc. Hashtable Special: Uses the methods like clone(), hashCode() and the values …

Hashtable Hash Code Example Read More »

Data Structures JDK 1.5 Features

Data Structures JDK 1.5 Features Summary: This tutorial "Data Structures JDK 1.5 Features", narrates the new features added to DS with JDK 1.5 JDK 1.5 brought many changes in data structures. It not only added a new DS Queue but also added extra features to the existing collections framework. Evolution of DS with JDK Versions …

Data Structures JDK 1.5 Features Read More »

Java Hashtable Program

Java Hashtable Program Summary: By the end of this tutorial "Java Hashtable Program", you will comfortable to write a program. Explained in simple terms with screenshot. Three Java Hashtable Programs are given. HashtableGeneral: Uses the methods like elements, containsKey, put, get, contains and keys. Hashtable Generics: Creates generics Hashtable storing strings and integers and uses …

Java Hashtable Program Read More »

Vector vs ArrayList

When to prefer Vector vs ArrayList? By functionality, both are very similar. Both are derived from List interface. The most important difference is that Vector methods are synchronized where as ArrayList methods are not. In a multithreaded environment, when a number clients access same instance where data is very critical and important, it is advised …

Vector vs ArrayList Read More »

Vector Example Special Operations

Four programs are given on Vector to know thoroughly about Vector, methods and usage. Vector is a general purpose data structure used very often by the programmer even though the collections framework comes with many classes. Vector – Methods: Uses all the methods of Vector class like capacity, size, firstElement etc. Generics Vector: Create generics …

Vector Example Special Operations Read More »

Java Vector Methods

Java Vector Methods Summary: The most used DS is Vector. Developer is required thorough with all the Java Vector Methods. Be comfortable to go through the tutorial. class Vector Vector internally is a array-based data structure (linked list is node-based) and grows dynamically when more elements are . Usage of Vector Constructors – Internal mechanism …

Java Vector Methods Read More »

Java Vector Generics Example

Java Vector Generics Example: About class Vector, its constructors and methods are explained very elaborately in the first program (and is advised to read before this program) Vector – Methods. Four Java Vector Generics Examples are given on Vector to know thoroughly about Vector, methods and usage. Vector is a general purpose data structure used …

Java Vector Generics Example Read More »

Java Generics Stack Example

Java Generics Stack Example: The following program creates generics stacks storing all ints, doubles, chars and strings. Java 5 enhanced for loop is used to print the elements. Two Java Generics Stack Examples are given on Java Generics Stack. First one is general stack storing any data types. The methods push, peek, pop, size etc. …

Java Generics Stack Example Read More »

Java UnsupportedOperationException

Java UnsupportedOperationException Summary: Java UnsupportedOperationException explained in simple words for a beginner. Possibility of throwing is illustrated. UnsupportedOperationException is thrown by the JVM at runtime. It is called when the method called is not supported by a data structure. java.lang.UnsupportedOperationException is paced in collections framework. Following is the class signature public class UnsupportedOperationException extends RuntimeException …

Java UnsupportedOperationException Read More »

Collections Hierarchy Java

After knowing the meaning and purpose of Collections framework, let us know the basic interfaces, derived classes and their properties. Java data structures are nothing but subclasses of Collection and Map interfaces. Following hierarchy gives all the interfaces of Collections framework. Fig: Basic interfaces of collections framework Map and SortedMap form a separate hierarchy and …

Collections Hierarchy Java Read More »

Java Interface Collection

Java Interface Collection Summary: Java Interface Collection is the super most interface from which almost all DS are derived. Explained the API in simple terms for a very beginner. Collection interface forms the base from which many data structures (almost all) are derived. The data structures derived from Collection interface are known as collections framework. …

Java Interface Collection Read More »

Enumeration vs Iterator

After practicing Enumeration and Iterator with examples, let us summarize the differences. Both Enumeration and Iterator are used for iterating elements of a data structure. Iterator, being latest, comes with more features tabulated below. Enumeration Iterator Introduced with JDK 1.0 Introduced with JDK 1.2 Cannot remove any elements Can remove elements from the original DS …

Enumeration vs Iterator Read More »

Java Iterator Interface Example

Java Iterator Interface Example: JDK 1.0 Enumeration is replaced by Iterator interface in JDK 1.2. Being latest, it comes with many advantages over Enumeration. Like Enumeration, Java Iterator interface is also used for iterating the elements. Java Iterator Interface Example import java.util.*; public class IteratorDemo { public static void main(String args[]) { Vector vect1 = …

Java Iterator Interface Example Read More »

ListIterator Example Methods

We have seen earlier iterating Vector elements with Enumeration and Iterator. Now let us see with ListIterator. ListIterator is derived from Iterator interface and comes with more methods than Iterator. Always, subclass is richer than super class. Following is the class signature public interface ListIterator extends Iterator We know between two interfaces extends should be …

ListIterator Example Methods Read More »