true
is tagged with the boolean
type.
sqrt(true)
???
int i; double sqrt(double x) { ... }
i = true;sqrt(true)
int
s, a stack for boolean
s, and so on.
void m() {Object
o = 42; }
void m() { Object o = newInteger
(42); }
primitive-typeValue()
in java.lang.Number
.
hashTable
maps String
s to int
s.
void m(String key) if (hashTable.containsKey(key)) int i = ((Integer) hashTable(key)).intValue()
void m() { Object o = 42; } void m(String key) { if (hashTable.containsKey(key)) int i = hashTable(key); }
class Dictionary void add(Key k, Value v) { ... } Value find(Key k) { ... } void delete(Key k) { ... } class LinkedListDictionary void add(Key k, Value v) { ... } Value find(Key k) { ... } void delete(Key k) { ... } class HashTableListDictionary void add(Key k, Value v) { ... } Value find(Key k) { ... } void delete(Key k) { ... }
A inherits from B A IS-A B
|
|
extends
class modifier signals inheritance:
class Child extends Parent { ... }
class Dictionary { void add(Key k, Value v) { ... } Value find(Key k) { ... } void delete(Key k) { ... } } class LinkedListDictionary extends Dictionary { }
class Blob { ... } class Spot extends Blob { ... } class Drop extends Blob { ... }
|
|
class Blob { ... } class Spot extends Blob { ... }
class Blob extends Object { ... } class Spot { ... } class Drop extends Spot { ... }
class Stack void push(Object o) { ... } Object pop() { ... }
stack.push("blah"); use(stack); stack.push(new Blob()); use(stack); stack.push(stack); use(stack);
use()
look like?
void use(Stack s) ??? e = (???) s.pop(); // and so on.