why there is a difference in behavior for copying contents in primitive and non primitive type?

  • copies the contents of RHS variable into LHS variable
  • primitives: the primitive value is copied (Call by value)
  • references: the address is copied (Call by reference)
  • implications: for references the object is not copied, it is shared (reference variables are aliases)
  1. Call by value:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aarthi K

Aarthi K

Hi All! I am Aarthi, a Software developer by profession and a budding technical blogger. I am here to feed my tech thirst 😁.