CoreJava


Collections


Duplicates

Null values

description
Array list
Yes,
yes
1)Reterival Purpose
2)DataStruture is Resizable or growable array
3)Insertion order preserved,
4)duplicates Objects allowed
5)null insertion possible
6)Hetrogenious Objects allowed
7)Implemented the following Marker interfaces
      1)Randam access interface
      2)serilizable interface
     3)clonnable Interface

Linked list
yes
yes
1)Insertion& deletion in middle purpose using
2)DataStruture is DoublyLinkedList
3)Insertion order preserved,
4)duplicates Objects allowed
5)null insertion possible
6) Hetrogenious Objects allowed
6)Implemented the following Marker interfaces
       1)serilizable interface
     2)clonnable Interface
Vector(legacy)
yes
yes
1)DataStruture is Resizable or growable array
2)Insertion order preserved,
3)duplicates Objects allowed
4)null insertion possible
5) Hetrogenious Objects allowed
6)Implemented the following Marker interfaces
      1)Randam access interface
      2)serilizable interface
     3)clonnable Interface

Stack


Child class of vector




Duplicates

Null values

Decription
Hashset(1.2)
no
Only Once
1)DataStruture is Hashtable
2)Insertion order  not preserved,
Based on Hashcode of object the data will be stored(some random order)
3)duplicates  not Objects allowed
      If we trying to add duplicate values
       It won’t through CTE(or)RTE,add()simply returns false
4)null insertion   possible only once
     If we trying to add duplicate null  values
       It won’t through CTE(or)RTE
5) Hetrogenious Objects allowed
6)Implemented the following Marker interfaces
      1)serilizable interface
     2)clonnable Interface
7)search purpose useful
LinkedHashset
no
Only Once
similarly to above,But
1)Datastruture is LinkedList+hashTable
2)Insertion order preserved
3)linkedhasshset&linkedhashmap are best suitable for Cache memory
Tree set









Eg:
TreeSet ts=new TreeSet();
ts.add(null);
ts.add("r");
system.out.println(ts);
O/P:
NullPointerException
raised
no
no
1)DataStruture is Balance Tree
2)Insertion order  not preserved,
 All the elements are  stored in some sorting order
3)duplicates  Objects not allowed
      If we trying to add duplicate values
       It won’t through CTE(or)RTE, it ignores the duplicate value
4)null insertion   not possible
     If we trying to add null  values
        It throws “NullPointerException”
5) Hetrogenious Objects not allowed
           If we trying to add other values it throws “ClassCastException”
6)Implemented the following Marker interfaces      1)serilizable interface
     2)clonnable Interface
7)Only Homogenious element allowed
8)search purpose useful


For Key:  “keyvalue” and “keynull value” the latest will remain, the past value will be gone
IOP:insertion order preserved       IONP:Insertion Order not preserved
DA:Duplicates Allowed         
DNA:Duplicates not allowed  ,NPE :Null Pointer Exception   CCE:Class Cast Exception
NIPOOFK: Null insertion is possible  Only once for Key   ,       DS:DataStruture

Dupicates
(key,value)
Null
(key,value)
description
HashMap
(1.2)
1)(jvm uses equals() to identify duplicates keys)

2)Domianate Garbage collector
(no,yes)
(yes(only once),yes)
1)HashMap under lying DS is HashTable
2) Insertion order  not preserved,
Based on Hashcode of object the data will be stored(some random order)
3)Hetrogenious and Homogenious objects are allowed for both key and values
Key(unique)
Value(may be duplicate)
DNA for key.
If we try to Insert duplicates as key ,it won’t throw Exception
The Latest   key and corresponding values present (past (key,value)pair gone)
Duplicate values are allowed .
Null insertion is possible for key only once .
 If we try to insert duplicate” null” as key ,it won’t throw Exception.the Latest “null” as key and corresponding value present (past (key,value)pair gone).
Similarly as above
Duplicate  “null” as values allowed
Hetrogenious keys allowed
Hetrogenious values allowed
LinkedHashmap
(1.4)
(no,yes)
(yes(only once),yes)
1)      similarly to above,But Insertion order   preserved
2)      linkedhasshset&linkedhashmap are best suitable for Cache memory




TreeMap(1.2)
(no,yes)
(no,yes)
1)TreeMap under lying DS -RED-BLACK SORT
2) Insertion order  not preserved,
 All the elements are  stored in some sorting order
3) Hetrogenious objects are not allowed for keys and Hetrogenious objects are  allowed for values
Key(unique)
Value(may be duplicate)
DNA for key.
If we try to Insert duplicates as key ,it won’t throw Exception
The Latest   key and corresponding values present (past (key,value)pair gone)
Duplicate values are allowed .
Null insertion is not possible for key .
 If we try to insert “null” as key then it throws
NullPointerException


Duplicate  “null” as values allowed
Hetrogenious keys not allowed
 If your try to insert hetrogenious keys then “Class Cast Exception”will trown
Hetrogenious values allowed
Only Homegenious keys allowed
Both Homegenious and Hetrogenious values allowed
For an empty TreeMap ,as first element “null” as key can be inserted then after no other (key,value)pair inserted
Eg:=
1)
TreeMap tm=new TreeMap();
tm.put(null,"v3");
System.out.println(tm);
O/P:[null,v3]
2) TreeMap tm=new TreeMap();
tm.put(null,"v3");
tm.put(1, "key");
System.out.println(tm);
O/P: NullPointerException raised
LinkedHashMap
(no,yes)
(no,yes)
Similar to HashMap ,But insertion order is reserved




IdentityhashMap
1)(jvm uses “==” to identify duplicates keys)
(no,yes)
(yes(only once),yes)
Similar to HashMap
 WeakHashMap
(no,yes)
(yes(only once),yes)
Similar to HashMap


1)LinkedHashMap                            =  HashMap
(Insertion order is preserved)        |  (Insertion order is not preserved)  
2)IdentityHashMap                          =HashMap
(JVM uses”==” operator to             |(JVM uses equals()  to isentify Duplicate keys)
Identify Duplicate keys)
3)WeakHashMap                            =HashMap
                 HashMap object is not eligiable for garabage collection.if it associated with hashMap even through,even through it doesnot have any external reference(i.e HashMap Dominates Garbage collector)
                   In  WeakHashMap  an object is not havaing any external reference then it is alwayseligiable for for garabage collectioneven through it associated with weakHashMap.(i.e., Garbage collector dominate the weakHashMap).

Ruffly Remember
     1)Any  “List” Insertion Order Preserved,Duplicates allowed,null value allowed
      2)Any     “Set” Insertion Order not preserved,Duplicated not allowed,null not allowed(varies some                           time)
       3)Any       “Tree” insertion Order not preserved,duplicates not allowed,Sorted order of elements(Default Ascending order)
     4)Map(key, value): Key Unique,value may be duplicate
====================================================================

Type of Cursors
1)Enumeration(i)(legacy)  --Forward
                 1)  Public Boolean hasMoreElements()
                  2)Public Object nextElement()    
2)Iterator(i)—Forward,Remove
                   1)  Public Boolean hasNext()
                  2)Public Object next()    
                   3) Public void remove()    

3)ListIterator(i)—Forward,Backward,Remove,Replace
                   1)  Public Boolean hasNext()
                   2) Public Boolean hasPrevious()
                  3)Public Object next()    
                 4) Public Object Previous ()    
                   3) Public void remove()    
 ======================================================================
Language fundamentals
1)Identifier
2)keywords
3)Datatypes
4)Literals
5)Arrays
6)Types of variables
7)var-args methods
8)java coding Standards
9)Commmand linearguments and the main()
Identifier: (Name of theVaribles,methods,classesand labels)
Consists of a sequence of characters (a toz) to Digits(0-9)or Currenbcy symbols($)orConnecting puncuvations(_)
Reserved Words(8+11+6+11+6+4+1+3+1)
DataTypes(8):bytet,short,int,long,float,double,Boolean,char
Flow Control(11):if,else,switch,case,default,for,do,while,break,continue,return
Exception Handling(6):try,catch,finally,throw,throws,assert
Modifier:Access specifiers(11) :(privateprotected,default,public)&(static,abstract,final,synchronized,native,transient,volatile,strictfp)
Class Relateed Keywords(6):interface,class,package,import,extends,implementas
Object related keyword(4):new,instanceof,super
Void return type key word(1)
Reserved literals(3):true,false(value for boolean dataype),null(value for object reference)
MSB(most significant bit )
0         ->+ive


1         ->-ve

No comments:

Post a Comment