The method sleep and wait sounds like doing the same task, but they are much different from each other. Sleep method belongs to the Thread class, and the wait method belongs to the Object class. The most important difference that distinguishes both of them is, the sleep method holds the lock on the object till it is interrupted or it finishes its execution. On the other hand, the wait method releases the lock on the object to let the other objects execute till is resumed by the notify method. … [Read more...]
Difference Between HashMap and LinkedHashMap in Java
HashMap and LinkedHashMap are the classes, quite similar to each other and are used for creating a map. HashMap class extends the AbstractMap class to use a hash table to store the elements in the map. LinkedHashMap class maintains the entries in the map based on their insertion order. The feature that distinguishes HashMap and LinkedHashMap from each other is that Hashmap does not maintain the order of the stored entries in a map. On the other hand, LinkedHashMap uses a hybrid data structure … [Read more...]
Difference Between List and ArrayList in Java
List and ArrayList are the members of Collection framework. List is a collection of elements in a sequence where each element is an object and elements are accessed by there position (index). ArrayList creates a dynamic array of objects that increases or reduces in size whenever required. The primary difference between List and ArrayList is that List is an interface and ArrayList is a class. Let us study the difference between the List and ArrayList with the help of comparison chart shown … [Read more...]
Difference Between Thread Class and Runnable Interface in Java
A thread can be defined in two ways. First, by extending a Thread class that has already implemented a Runnable interface. Second, by directly implementing a Runnable interface. When you define a thread by extending Thread class you have to override the run() method in Thread class. When you define a thread implementing a Runnable interface you have to implement the only run() method of Runnable interface. The basic difference between Thread and Runnable is that each thread defined by … [Read more...]
Difference Between extends and implements keywords in Java
The keywords extends and implements are used to inherit the features of an already existing parent block in newly created child block. Using extends keyword, a newly created class (subclass) can inherit the features of an existing class (superclass). Using implements keyword a newly created class can implement all the methods of an interface. The primary difference between keywords extends and implements is that a class extends another class to inherit all its members whereas, a class … [Read more...]
Difference Between Data Hiding and Encapsulation
Data hiding and encapsulation both are the important concept of object oriented programming. Encapsulation means wrapping the implementation of data member and methods inside a class. When implementation of all the data member and methods inside a class are encapsulated, the method name can only describe what action it can perform on an object of that class. Data Hiding means protecting the members of a class from an illegal or unauthorized access. The main difference between data hiding and … [Read more...]
Difference Between Class and Interface in Java
Class and Interface both are used to create new reference types. A class is a collection of fields and methods that operate on fields. An interface has fully abstract methods i.e. methods with nobody. An interface is syntactically similar to the class but there is a major difference between class and interface that is a class can be instantiated, but an interface can never be instantiated. So let us learn some more difference between a class and interface with the help of a comparison chart … [Read more...]
Difference Between List and Set in Java
List and Set interface extends Collection. Both of them maintains the collection of elements or objects. But, the major difference that distinguishes them from each other is List is a collection of ordered element, the elements are added or remove or accessed with the help of an index variable. On the other hand, Set is a collection of objects where the collection does not allow duplicate elements in it. Let us study some more differences between List and Set interfaces with the help of … [Read more...]
Difference Between HashMap and Hashtable in Java
The HashMap and Hashtable, both are used to represent a group of objects that are represented in <Key, Value> pair. Each <Key, Value> pair is called Entry object. The collection of Entries is referred by the object of HashMap and Hashtable. Keys in a collection must be unique or distinctive. The difference between HashMap and Hashtable is that HashMap particularly implements the Map interface whereas, the Hashtable extends the Dictionary class (legacy class) which is reengineered … [Read more...]
Difference Between ArrayList and Vector in Java
ArrayList and Vector both are the classes under Collection Framework hierarchy. ArrayList and Vector, both are used to create a dynamic array of objects where the array can grow in size as and when required. There are two basic differences that distinguish ArrayList and Vector is that Vector belongs to Legacy classes that were later reengineered to support the collection classes whereas, an ArrayList is a standard collection class. Another important difference is that ArrayList is … [Read more...]
- « Previous Page
- 1
- …
- 5
- 6
- 7
- 8
- 9
- …
- 12
- Next Page »