2015-04-20 15:36:01 -07:00
|
|
|
|
//: initialization/Mugs.java
|
2015-05-29 14:18:51 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
2015-04-20 15:36:01 -07:00
|
|
|
|
// Java "Instance Initialization."
|
|
|
|
|
import static net.mindview.util.Print.*;
|
|
|
|
|
|
|
|
|
|
class Mug {
|
|
|
|
|
Mug(int marker) {
|
|
|
|
|
print("Mug(" + marker + ")");
|
|
|
|
|
}
|
|
|
|
|
void f(int marker) {
|
|
|
|
|
print("f(" + marker + ")");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Mugs {
|
|
|
|
|
Mug mug1;
|
|
|
|
|
Mug mug2;
|
|
|
|
|
{
|
|
|
|
|
mug1 = new Mug(1);
|
|
|
|
|
mug2 = new Mug(2);
|
|
|
|
|
print("mug1 & mug2 initialized");
|
|
|
|
|
}
|
|
|
|
|
Mugs() {
|
|
|
|
|
print("Mugs()");
|
|
|
|
|
}
|
|
|
|
|
Mugs(int i) {
|
|
|
|
|
print("Mugs(int)");
|
|
|
|
|
}
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
print("Inside main()");
|
|
|
|
|
new Mugs();
|
|
|
|
|
print("new Mugs() completed");
|
|
|
|
|
new Mugs(1);
|
|
|
|
|
print("new Mugs(1) completed");
|
|
|
|
|
}
|
|
|
|
|
} /* Output:
|
|
|
|
|
Inside main()
|
|
|
|
|
Mug(1)
|
|
|
|
|
Mug(2)
|
|
|
|
|
mug1 & mug2 initialized
|
|
|
|
|
Mugs()
|
|
|
|
|
new Mugs() completed
|
|
|
|
|
Mug(1)
|
|
|
|
|
Mug(2)
|
|
|
|
|
mug1 & mug2 initialized
|
|
|
|
|
Mugs(int)
|
|
|
|
|
new Mugs(1) completed
|
|
|
|
|
*///:~
|