Introduction To Programming With Java
Introduction To Programming With Java
parameter
Return value
function
Remember from Math
Another function
How Objects Behave
The size effects the bark
Instance variables
(state) Dog
size
name knows
methods
(behavior)
bark() does
Send things to a method
d.bark(3); //bark three times
z
• void go (int z) { }
copy
• foo.go(x); x z
• void go(int z) {
z = 0; x z
}
x an z aren’t
connected
Get things back
• int theSecret = life.giveSecret();
These types
must match
• int giveSecret() {
return 42;
}
Bullet Points
• Classed define what an object knows and what
an object does
-x Conditional
x
UnaryOperator<Double> fx = x->x<0
? -x
: x;
Fibonacci Numbers
n 0 1 2 3 4 5 6 7 8
1 1 2 3 5 8
Fibonacci Numbers
http://www.bloomberg.com/graphics/2015-paul-ford-what-is-code/