Line | |
---|
1 | package testcode;
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Tests static function calls and references
|
---|
5 | */
|
---|
6 | public class Static {
|
---|
7 |
|
---|
8 | public static String OK = "ok1";
|
---|
9 | private static String Y;
|
---|
10 | public static int S = 0;
|
---|
11 |
|
---|
12 | static {
|
---|
13 | int S = 1; // not overriding the public S
|
---|
14 | Y = "ok3";
|
---|
15 | }
|
---|
16 |
|
---|
17 | public Static() {
|
---|
18 | System.out.println(f());
|
---|
19 | System.out.println(S == 0 ? "ok2" : "ko2");
|
---|
20 | System.out.println(Y);
|
---|
21 | }
|
---|
22 |
|
---|
23 | private static String f() {
|
---|
24 | return OK;
|
---|
25 | }
|
---|
26 |
|
---|
27 | /**
|
---|
28 | *
|
---|
29 | * @param args the arguments of the call.
|
---|
30 | */
|
---|
31 | static public void main(String[] args) {
|
---|
32 | new Static();
|
---|
33 | }
|
---|
34 |
|
---|
35 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.