Found 9344 Articles for Object Oriented Programming

Difference Between InputStream and OutputStream in Java

Rudradev Das
Updated on 19-Oct-2023 13:23:58

581 Views

InputStream and OutputStream both are the abstraction process which can be implemented to access the low level data sets as pointers . They are the signified APIs to specify a particular data sequence of an operation by following some individual steps. The InputStream rearranges a data set as an ordered stream of bytes which actually reads the data from a file or received by using a network system. After ending the stream process it will return -1 as an integer value as Java does not contain any unsigned byte as data type. An OutputStream is a streamed process which mainly ... Read More

Difference between Inheritance and Interface in Java

Rudradev Das
Updated on 19-Oct-2023 13:22:02

664 Views

Inheritance is a Method to create a hierarchy between multiple classes by replicating some properties from others. There are various types of inheritance present in Java, such as single inheritance, multiple inheritance, multilevel inheritance, hybrid inheritance, and hierarchical inheritance. Interface is the blueprint of a particular class which consists of the constant and abstract class. The interface class allows a machine to apply some specific properties on an object or a class. It is totally an abstract method which helps to perform the Java abstraction on a collection by specifying the behavior of a class. Now the task ... Read More

Difference Between IdentityHashMap, WeakHashMap, and EnumMap in Java

Rudradev Das
Updated on 02-Nov-2023 17:58:08

154 Views

The IdentityHashMap is a special type of hash class by which we handle the rare cases related to the reference-equality. This map compares the keys by using a " = = " operator where the normal hashmap uses the " equals " method for this. A Weak HashMap is a type of map interface where the hash table merges its keys with the weak reference type of values. This type of map class can not be used further just because of the lack of reference pointers. An enum map is a special type of map class which contains only the ... Read More

Difference Between Hashtable and Synchronized Map in Java

Rudradev Das
Updated on 02-Nov-2023 18:18:26

142 Views

A HashTable is a compact abstract data set which converts the keys of a map to the values by computing the indexes into an array of slots to enable faster data access. On the other hand, a synchronized map is a Java collection class which is mainly used to synchronize a particular map to make it a thread safe collection and can be applied on a whole object. The map does not contain any null value. Input [ ARB, RDD, KOL, DHKA ] Output Insertion Order of objects in HashTable : [ ARB, RDD, KOL, DHKA ] Insertion Order of objects in Synchronized Map : [ ... Read More

Difference between HashMap and IdentityHashMap in Java

Rudradev Das
Updated on 02-Nov-2023 18:20:39

95 Views

HashMap and IdentityHashMap are the key value data sets which are used to access the key data pairs. More specifically. A HashMap is a Java collection framework which provides the functionality of a proper hash table data set. The map stores the element value as a key or pairs which are the unique identifiers in nature. This map also permits the null values as a non synchronized class. The IdentityHashMap is a special type of hash class by which we handle the rare cases related to the reference-equality. This map compare the keys by using a " = = " operator ... Read More

Difference and similarities between HashSet , LinkedHashSet and TreeSet in Java

Rudradev Das
Updated on 02-Nov-2023 17:50:59

112 Views

The HashSet, LinkedHashSet and TreeSet are the set interface class mainly used to store the elements. HashSet − A HashSet is a container instance which stores the unique elements only in a non synchronized manner to handle the high-performance operations involving with the set. The set allows the null values which does not follow the order of insertion. LinkedHashSet − The LinkedHashSet is a cloned data structure which have the both facilities of a hashtable and linked list as a set interface. The ordered version of a LinkedHashSet always works as a doubly linked list on over the input elements. TreeSet ... Read More

How to iterate LinkedHashMap in Java?

Deepti S
Updated on 19-Oct-2023 12:23:08

569 Views

LinkedHashMap is a class that is identical to HashMap, however it additionally provides a feature that tracks the order wherein components are inserted. The sequence wherein elements were added isn't preserved by using HashMap, even though it does permit for quick element insertion, search, and deletion. By keeping a linked list of every entry in the map, LinkedHashMap addresses this issue. The elements are saved in the sequence that they were introduced thanks to this linked list. As a result, while iterating over a LinkedHashMap, the elements are returned according to how they were added. Methods Used To iterate LinkedHashMap ... Read More

How to Iterate Through HashTable in Java?

Deepti S
Updated on 19-Oct-2023 12:20:05

463 Views

The HashTable is a fundamental data structure that operates on the basis of key hashcodes without preserving the insertion order. It prohibits duplicate keys but allows for duplicate values. Remarkably, it accommodates a wide range of objects for both keys and values, fostering heterogeneity. Null values for keys and values are not allowed, though, as doing so would cause a RunTimeException called a NullPointerException. The HashTable implements the serializable and cloneable interfaces in terms of interfaces, but it fails to implement the RandomAccess interface. Additionally, all the methods within the HashTable are synchronized, ensuring thread safety for HashTable objects. When ... Read More

How to Iterate LinkedList in Java?

Deepti S
Updated on 19-Oct-2023 12:16:22

58 Views

The LinkedHashMap Class is similar to HashMap. But it has an additional feature in comparison to HashMap. The LinkedList class belongs to the java.util package. A doubly linked list is how LinkedList stores its elements. Given that our operations typically include insertion and deletion, LinkedList is the best option. The java.util package contains the LinkedList collection framework. It acts as an implementation of the non-contiguous LinkedList data structure, which saves elements in memory. Methods Used There are five main methods that you can use for iterating HashMap − Using the for loop Making use of a while loop Using ... Read More

How to Iterate the Vector Elements in the Reverse Order in Java?

Deepti S
Updated on 18-Oct-2023 16:35:11

79 Views

The Vector class has been a part of the Java collection system since Java version 1.2. Vectors are sometimes known as Dynamic Arrays because, unlike ordinary arrays, they can expand and contract in size. Ensuring thread-safety, Vectors are synchronized. While there exists a third approach that involves using Apache Commons to iterate through the vector in reverse, this method necessitates the downloading of additional jar files and packages, which is not widely supported by most systems. Essentially, there are only two primary methods to traverse through vector elements in reverse order. Methods Used There are two methods used here − ... Read More

Advertisements