Integer, Short, Long, Byte, Boolean, Float, Double, Character
Why Wrapper class?
Consider HashSet<Integer>
int, short, long, byte, boolean, float, double, char
The most Important class in Java
hashCode() & equals()
Difference for String in Java and C++
wait(), notify(), notifyAll()
Thread and Process: Similarity and Difference
finalize()
Stack
stack memory is used only by one thread of execution
stack memory cannot be accessed by other threads
stack memory is short-lived
When stack is full, it throws StackOverFlowError
Heap
heap memory is used by all the parts of the application
objects stored in the heap are gloabally accessible
heap memory lives from the start till the end of application execution
When it is full, it throws OutOfMemoryError
Stack
very fast access
don't have to explicitly de-allocate variables
space is managed efficiently by CPU, memory will not become fragmented local variables only
limit on stack size (OS-dependent)
variables cannot be resized
Heap
no limit on memory size but (relatively) slower access
no guaranteed efficient use of space, memory may become fragmented over time as blocks of memory are allocated, then freed
you must manage memory (you're in charge of allocating and freeing variables)
variables can be resized using realloc()
Integer -> 4 bytes -> 32 bits
Long -> 8 bytes -> 64 bits
Boolean/Char -> 1 byte
The benefit of write-through to main memory is it simplifies the design of the computer system. With write-through, the main memory always has an up-to-date copy of the line. Main memory can always reply with the requested data.
If write-back is used and the data is in a processor cache, then that processor must stop main memory from replying to the read request, because the main memory might have a stale copy of the data. This is more complicated than write-through.