Java

Java is a strongly typed, garbage collected language that runs in the JVM. It can run on almost anything.

Data structures

C++ DS Java DS Notes
Vector ArrayList Threadsafe
Vector Vector Not threadsafe; deprecated
Deque Deque  
Stack Stack Stack implementation using a vector
List ArrayList Both linked lists; Singly linked
List LinkedList Doubly linked list
Map TreeMap Red-black tree
Set TreeSet Red-black tree
unordered_set Hashset Hashtable
unordered_map Hashmap Non blocking but race conditions can occour
unordered_map Hashtable Threadsafe but blocking; deprecated
N/A LinkedHashMap LRUCache; Hash table that knows order of elements inserted/accessed
N/A LinkedHashSet LRUCache; Hash set that knows order of elements inserted/accessed

Primatives

Name Size (bits)
byte 8
short 16
int 32
long 64
float 32
double 64
char 16
boolean 1

Classes

Constructor

    public class MyClass{
        public MyClass(){
            //constructor code here
        }
    }

Copy Constructor

    public class MyClass{
        public MyClass(MyClass myclass){
            //copy constructor here
        }
    }

Deconstructor/Finalize

finalize provides security and is called by the garbage collector. We can call it directly to clean up the object. All exceptions thrown by it are ignored by the garbage collector.

    public class MyClass{
        public MyClass(){
            //constructor code here
        }

        protected void finalize(){
            //clean up code here
        }
    }

Keywords

C++ Java Notes
const final Sets a value to be unchangable; aka immutable