Optimize Java Code Performance

In this article, we are going to discuss Java Code Performance Optimization Tip.

While creating the POJO/Entity/Model, we need to choose the data type wisely.

  1. Use Primitive data type over Objects
  2. Because the Primitive data type is stored on stack memory and Objects stored on heap memory.
  3. Data access from stack memory is faster than heap memory, hence the better choice is the primitive data type.

For example, boolean over Boolean(wrapper class), int over Integer and double over Double

     private int Id;
     private double Price;