References are dangerous

  • Variables in Java are labels for data that exists in memory
  • Variables do not "store" data. They point to data
  • Passing objects as parameters to methods in Java passes a reference
  • Those functions can go and modify the underlying data
  • It is important who has ownership over data

20 / 23