-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathTest.java
More file actions
47 lines (36 loc) · 906 Bytes
/
Test.java
File metadata and controls
47 lines (36 loc) · 906 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
44
45
46
47
import java.lang.Thread;
public class Test {
Thread myThread;
public Test() {
myThread = new Thread("myThread");
// BAD
myThread.start();
}
public static final class Final {
Thread myThread;
public Final() {
myThread = new Thread("myThread");
// OK - class cannot be extended
myThread.start();
}
}
private static class Private {
Thread myThread;
public Private() {
myThread = new Thread("myThread");
// OK - class can only be extended in this file, and is not in fact extended
myThread.start();
}
}
public static class AllPrivateConstructors {
Thread myThread;
private AllPrivateConstructors() {
myThread = new Thread("myThread");
// OK - class cannot be extended outside this file, and is not in fact extended
myThread.start();
}
public static AllPrivateConstructors create() {
return new AllPrivateConstructors();
}
}
}