Sunday 18 September 2016

literal and new

12.6 Difference b/w literal and new

Difference between creating String object by literal and new operator.
  • We have already seen the creating of String objects in three ways.
  • Now its time to get to know mainly the difference between creating String object by using literal and new.
  • Only String class having two types of memory locations to store String objects which are Heap and String Constant Pool memory.(SCP)
  • Here SCP is available inside Heap memory.
                                                                              
  • Based on the type of String object creation, these objects will be stored either in heap or String Constant Pool memory.
Thanks for your time.
Nireekshan