Tryst with Java Language

Java rite way

Thread has it’s own memory space — April 5, 2016

Thread has it’s own memory space

Each Java Virtual Machine thread has a private Java Virtual Machine stack, created at the same time as the thread.

Whereas Heap is shared across.

The Java Virtual Machine has a heap that is shared among all Java Virtual Machine threads.

References:

Boxing & UnBoxing — February 23, 2016

Boxing & UnBoxing

  • Boxing?
    output_u5b194
    Converts expressions of primitive type to corresponding expressions of reference type.
    int intValue = 0;
    Integer intObject = intValue;bytecode:For Boxing Java compiler uses valueOf() instead of constructor. This is beneficial since it allows for caching, and doesn’t force the creation of a new object on each boxing operation.

  • Un-Boxing?
    output_IIY77l
    Converts expressions of reference type to corresponding expressions of primitive type.
    Integer intObject = new Integer(0);
    int intValue = intObject;

    bytecode:
    For Un-Boxing Java compiler uses intValue(), which Returns the value of this Integer as an int.
Reference: