-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestInterview.java
More file actions
73 lines (64 loc) · 1.83 KB
/
TestInterview.java
File metadata and controls
73 lines (64 loc) · 1.83 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
package com.xp.java;
import java.util.ArrayList;
import java.util.List;
//一些java 面试题
public class TestInterview {
static class ValHold {
public int i = 10;
}
public void amethod() {
int i = 99;
ValHold v = new ValHold();
v.i = 30;
another(v, i);
System.out.println(v.i);
}
public void another(ValHold v, int i) {
i = 0;
v.i = 20;
ValHold vh = new ValHold();
v = vh;
System.out.println(v.i + "" + i);
}
//字符串考察
public static void testConcat() {
String product = "Pen";
product.toLowerCase();
product.concat(" BOX".toLowerCase());
System.out.println(product);
System.out.println(product.substring(4, 6));
}
public static int weiSum() {
int a = 4;
int result = a++ + 4 << 2;
return result;
}
public static String fun(String s) {
return s.length() < 0 ? (fun(s.substring(1) + s.charAt(0))) : "";
}
//考察 集合删除
public static void listRemove() {
List<String> dataList = new ArrayList<>();
dataList.add("a");
dataList.add("b");
dataList.add("c");
dataList.add("d");
dataList.add("e");
for (int i = 0; i < dataList.size(); i++) {
String data = dataList.get(i);
System.out.print("i = " + i);
System.out.println(" data = " + data);
if ("c".equals(data) || "d".equals(data)) {
dataList.remove(data);
}
}
System.out.println("dataList = " + dataList);
}
public static void main(String[] args) {
// TestInterview outer = new TestInterview();
// outer.amethod();
// testConcat();
// System.out.println(weiSum());
listRemove();
}
}