primitive type: char, int, double, float, long etc. where is the data stored? In the memory location of the variable copy semantics: when one primitive type variable is assigned the value of another variable, it copies the value, and the two variables are independent entities. We say that one is a deep copy of the other. int x = 10; int y = x; x++; System.out.println(y); What part of the memory do primitive types come from? the stack segment. A programmer cannot create their own primitive types in Java. All primitive types are implemented and can't be extended or modified. What happens when you pass a primitive type to a method? public static void change(int x) { x++; } int y = 11; change(y); println(y); ------------------------------- Reference types: String, arrays, File, Scanner, Integer, etc. where is the data stored? A reference variable can store the address of an Object. The Object itself stores primitive types or reference types to other pieces of data (instance variables). copy semantics: when one reference type variable is assigned the value of another variable, it copies the value which is an address. What happens is that both reference variables refer to the same object, and any change in one is changed in both. This is called aliasing. Student s = new Student("Ari".....); Student t = s; s.setFirstName("A"); System.out.println(t.getFirstName()) -> A. What part of the memory do reference types come from? The reference variable itself is from the stack segment, but the objects that they reference are dynamically allocated from the heap segment. A programmer can create their own reference types in Java. A programmer can also extend other reference types, both built in and programmer defined. What happens when you pass a reference type to a method? The parameter becomes a temporary alias for the object that the calling method's reference refers to. Any change to the object in the method is permanent in the calling method. ------------------------------------- Every class in Java inherits behavior from the Object class. The Object class defines basic behavior that all Objects have in common. Two methods in particular that we have to worry about right now. public String toString(): default behavior: converts an Object into a String that has the Object's address and class name. intended behavior: to convert an object into a String by creating a representation for the Object. public boolean equals(Object obj) default behavior: does the same as ==. intended behavior: determines whether 2 objects have the same representation. Solution: To override the toString() and equals() methods. To override a method means to rewrite a method that exists in a superclass to make it do something it do something more specific.