void change(int[] x, int[] y) {
int[] temp = x;
x = y;
y = temp;
x[0] = 99;
}
int[] a = {1, 2, 3};
int[] b = {4, 5, 6};
change(a, b);
Why does this not change?
The copies of the REFERENCES are being swapped.
The original values stay the same.
What is an object? What does it store?
What are the parts of declaring a class?
Instance variables, constructors, and methods.
What are methods?
Getters, setters, etc.
What is inheritance?
A child class inherits states and behaviors from the parent
How do you create a SuperArray object?
SuperArray name = new SuperArray()
How do you add something to a SuperArray?
name.add(“thing”)
What does print do for a SuperArray?
Prints out everything but null elements.
If nothing is given for an index in a SuperArray, what is automatically placed at that index?
null
What is the code for catching an exception?
try { //block of code }
catch { //code executed when exception happens}
finally { //optional }
How do you print out the stack trace?
e.printStackTrace();
What is the variable name commonly placed with an exception while catching?
e
How do you throw an exception?
throw new NameOfException (“Message”)
What are some examples of wrapper classes?
Boolean, Character, Integer, Double
How can you simplify this statement?
Integer y = Integer.valueOf(3);
Integer myInt = 3;
How do you declare an ArrayList?
ArrayList< Type > name = new ArrayList< Type >();
How do you import the ArrayList class?
import java.util.ArrayList;
When do you use an ArrayList over an Array?
You do not know how many items you need.
You want to remove or add items to the list.