-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathFlexibleConstructors.java
More file actions
95 lines (79 loc) · 1.65 KB
/
FlexibleConstructors.java
File metadata and controls
95 lines (79 loc) · 1.65 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class A {
A(String msg) {
System.out.println("A: " + msg);
}
}
class B extends A {
B(String input) {
var msg = input.trim().toUpperCase();
super(msg);
}
}
class C {
private final int x;
C(int x) {
if (x < 0) throw new IllegalArgumentException();
super();
this.x = x;
}
}
record R(String name, int score) {
public R(String name) {
var score = name.length();
this(name, score);
}
}
class Outer {
private final String prefix = "outer";
class Inner {
private String full;
Inner(String suffix) {
var combined = prefix + "_" + suffix;
super();
this.full = combined;
}
}
}
class D {
private final String value;
private final int length;
D(String input) {
var processed = input.toLowerCase();
value = processed;
this.length = processed.length();
super();
}
}
class E extends A {
private boolean isValid;
private String processed;
E(String data) {
var temp = data != null ? data.trim() : "";
this.processed = temp;
isValid = !temp.isEmpty();
super(temp);
}
}
class F {
private int x;
private final int y;
private int sum;
F(int a, int b) {
x = a;
this.y = b;
this.sum = a + b;
super();
}
}
class G {
private String instance_val;
{
instance_val = "instance";
}
G(String input) {
var tmp = input != null ? input : "default";
var string = tmp + "_initialized";
super();
this.instance_val = string;
}
}