-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeetle.java
More file actions
43 lines (33 loc) · 844 Bytes
/
Beetle.java
File metadata and controls
43 lines (33 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//: reusing/Beetle.java
// The full process of initialization
package com.reusing07;
class Insect {
private int i = 9;
protected int j;
Insect() {
System.out.println("i = " + i + ", j = " + j);
j = 39;
}
private static int x1 = printInit("static Insect.x1 initialized!");
static int printInit(String s) {
System.out.println(s);
return 49;
}
}
public class Beetle extends Insect {
private int k = printInit("Beetle.k initialized");
public Beetle() {
System.out.println("k = " + k);
System.out.println("j = " + j);
}
private static int x2 = printInit("Beetle.x2 initialized");
static int printInit(String s) {
System.out.println(s);
return 39;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Beetle Constructor");
Beetle b = new Beetle();
}
}