| Classes – variables – methods : |
private : allow access only to the current class.
public : allow access to everybody regardless of the package.
protected : allow access only to subclasses or class of the same package.
default : allow access only to class of the same package.
transient : variable is not a part of a persistent object
final : class can’t be extended, method can’t be overriden and variable can’t be reinitialised.
static : class variable and not instance of class variable (useful for class constant used with final), class method can be called without create an instance of the class,
volatile : indicates that a thread must reconcile its working copy of the field with the master copy every time it accesses the variable.
| Classes – Interfaces : |
Implements : a class can implements several interfaces, but can extend only one class.
Extends : a class can only extend one another class, interface can extend an another interface.
Interfaces and Abstract classes do not need to fully implement the interfaces they respectively extend or implement
| Collections : Set, List & Map : |
Set : contains unique objects and no null elements are inserted.
HashSet : (Faster) but there absolutely no order.
TreeSet : (Normal) Object inside the set must implement the Comparable interface and compareTo method.
LinkedHashSet : (Slower) The order is respected regarding the order of objects inserted.
List : could contains null elements and duplicated objects, the order how the elements has been inserted is keeped.
ArrayList : (Faster) To get indexed element. (Slower) To delete or insert element.
LinkedList : (Faster) To remove or insert element. (Slower) Have to traverse the list to get an element.
Map : contains a pair of element of key/object.
HashMap : No ordering.
TreeMap : Key ordering.
LinkedHashMap : Preserves the insertion order.
HashTable : is a synchronized hashmap.
| Interface: Comparator & Comparable : |
Comparator : To implement as an utility to compare two objects and override compare() method;
Comparable : To implement on the object to compare and override compareTo() method;