-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYourErrorPatterns.java
More file actions
56 lines (43 loc) · 1.28 KB
/
Copy pathYourErrorPatterns.java
File metadata and controls
56 lines (43 loc) · 1.28 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
public class YourErrorPatterns {
public static void main(String[] args) {
YourErrorPatterns t = new YourErrorPatterns();
t.objReferenceIsImmutable();
}
public TreeNode checkWhyLoopBreaks(String data, int[] start) {
int i = start[0];
while (i < data.length()) {
if (data.charAt(i++) == ',')
break;
}
// #exit always check why the while loop breaks.
// #exit do this by starting with a template when more than one condition trigger loop breaks.
String sub = null;
if (i == data.length()) {
sub = data.substring(start[0], i);
} else {
sub = data.substring(start[0], i - 1);
}
start[0] = i;
if (sub.equals("null"))
return null;
return new TreeNode(Integer.valueOf(sub));
}
public void objReferenceIsImmutable() {
TreeNode t = Utils.treeDeserializer("1,2,3");
testTreeZ(t);
Utils.print(String.valueOf(t.left.val));
if(t.val == -1) {
Utils.print("should not see this");
}
}
public void testTreeZ(TreeNode t) {
// #enter you can not let t == null, but you can let t.left == null. and you can change t's value
//t.left = null; will work
//t = null. WONT work
//t.val = -2 will work
t.left.val= -2;
}
public void testStr(String s) {
s = "should not see this";
}
}