Submitted by heartin on Tue, 10/06/2015 - 00:12
You can sort a list of integers based on their natural ordering. You can compare two integers and see which one comes before the other in natural ordering. But how will you compare two objects and sort them in an order. You have two interfaces in Java Comparable and Comparator that will help us compare objects and sort them in an order.
Submitted by heartin on Mon, 10/05/2015 - 22:32
equals()
Method equals check if two objects are equal.
String class and most collection classes overrides equal to check if two objects are meaningfully equal, which means, if two different string objects have the same value.
The equals method for class Object will return true, for any non-null reference values x and y, if x and y refer to the same object.
Submitted by heartin on Mon, 10/05/2015 - 12:45
Generics language feature in Java allow you to write a class using generic types which can then be substituted with any type before actually using it. Generics allow you to write reusable and type safe code.
For example, you can write a generic linked list. The data in the linked list can be one of String, Integer or any other class type. The actual type needed to be decided only before using it and while creating the class you need to create only one reusable generic class.
Submitted by heartin on Tue, 10/21/2014 - 09:23
Collection framework in Java provides efficient implementations for commonly used data structures like list, set, queue, map etc. We can reuse these implementations without writing our own implementations when we need to use these data structures.
Submitted by heartin on Thu, 09/13/2012 - 20:03
Both Enumeration and Iterator are interfaces in Java for getting successive elements. Enumeration is older while iterator was introduced later with some improvements. Iterator has taken the place of Enumeration in the Java collections framework. ListIterator is a sub-interface of Iterator and allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list.
Pages