50 lines
840 B
Java
50 lines
840 B
Java
// housekeeping/Mugs.java
|
|
// ©2015 MindView LLC: see Copyright.txt
|
|
// Java "Instance Initialization."
|
|
import static com.mindviewinc.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
|
|
*/
|