Please enable JavaScript.
Coggle requires JavaScript to display documents.
Java (Object Class (List of methods
clone
equals
finalize
…
Java
Object Class
List of methods
- clone
- equals
- finalize
- getClass
- hashCode
- notify
- notifyAll
- toString
- wait
- == Compares references
- .equals compares references and values
- Contract b/n equals and hashCode methods are if comparison of two objects returns true then hashCode of two objects must be same
String Class
Facts about Strings
- Array of Characters
- String is a class, not primitive type
- Immutable and Final in java
- JVM uses String pool to store all strings
- String can be instantiated using "" or + or new
- Constructors are available in char array, byte array
String buffer and String builder to create string
- String created with double quotes ("") - Looks for JVM string pool for any existing string with same value and return the reference if available.
- String created with new operator. Won't look string pool or created string in JVM string pool. You can use intern method to save string in string pool
- String created with double quote will create in String pool of heap memory
- String created with new keyword will create in Heap memory
- If you compare String s1 = "Mohan"; against String s2 = new String("Mohan"); s1.equals(s2) will be false as the
references won't match event though the values matches.
-
Multithreading
Threads
Life cycle
-
Running
- sleep() takes to Sleeping state
- wait() takes to waiting state
- stop() takes to dead state
- I/O request etc takes to blocked state
- Time expires goes back to Ready state
-
Waiting
- notify() takes back to ready state
- notify() takes back to ready state
-
-
- Light weight process
- Separate path of execution because each thread will have separate stack space.
- Cost of communication between threads is low.
-
-
Memory Management
JVM Heap Memory
Young Generation
-
Survivor Memory (S0 , S1)
-
-
- New objects creates in Eden memory
- Eden memory full, minor GC triggers, all survior objects move to one of the survivor space
- Object survived after many cycles (threshold) will be move to old generation
- Major GC trigger when old generation is full
Garbage collection
- Marking
- Normal Deletion
- Deletion with compact
Garbage Collection Types
- Serial GC
- Parallel GC
- Parallel Old GC
- Concurrent Mark Sweep
- G1 GC
- jstat -gc 9582 1000
- 9583 is process id and 1000 is run for every one second
- jstat is a command line tool for monitoring GC