Boolean trouble or something

  • Variables/fields/parameters store a single value.
  • They range from 1 byte to 8 bytes in most languages.
  • At the statement m = new PVector(); the operator new creates a contiguous memory block enough to fit in all PVector’s non-static fields.
  • And when it’s done, it returns the 1st memory address of that block.
  • And finally, that 1st memory address is stored in the field m as a reference value.
  • Now, when you do pressLoc = m, you’re assigning field pressLoc w/ the exact value of m.
  • After that assignment, both m & pressLoc fields point to the same PVector object, b/c they now store the same 1st memory address value of it.
  • In other words, they’re now alias to the same object.
3 Likes