Skip to content

Commit 73e0424

Browse files
author
zhaoyuanli6
committed
迭代器删除测试,枚举类的识别测试
1 parent a80240a commit 73e0424

3 files changed

Lines changed: 68 additions & 5 deletions

File tree

src/main/java/com/code/repository/controller/HelloController.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import org.springframework.web.bind.annotation.RequestMapping;
44
import org.springframework.web.bind.annotation.RestController;
55

6+
import java.util.HashSet;
7+
import java.util.Iterator;
8+
import java.util.Set;
9+
610
@RestController // combines @Controller and @ResponseBody
711
public class HelloController {
812

@@ -14,4 +18,27 @@ public String index(String name) {
1418

1519
return "Hello "+name;
1620
}
21+
22+
public static void main(String[] args){
23+
24+
System.out.println(TestEnum.valueOf("ALIEXPRESS").getId());
25+
26+
27+
Set<String> data = new HashSet<>();
28+
data.add("q");
29+
data.add("w");
30+
data.add("e");
31+
32+
Iterator<String> it = data.iterator();
33+
while (it.hasNext()){
34+
String value = it.next();
35+
if(value.equals("w")){
36+
it.remove();
37+
}
38+
}
39+
40+
System.out.println(data);
41+
42+
}
43+
1744
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.code.repository.controller;
2+
3+
/**
4+
* @Author zhaoyuan.lizy on 2019/9/21
5+
**/
6+
7+
public enum TestEnum {
8+
LAZADA("1", "Lazada"),
9+
ALIEXPRESS("2", "AE"),
10+
TMALL("3", "TMW"),
11+
Alibaba("4", "1688");
12+
13+
private String id;
14+
private String name;
15+
16+
public String getId() {
17+
return this.id;
18+
}
19+
20+
public void setId(String id) {
21+
this.id = id;
22+
}
23+
24+
public String getName() {
25+
return this.name;
26+
}
27+
28+
public void setName(String name) {
29+
this.name = name;
30+
}
31+
32+
private TestEnum(String id, String name) {
33+
this.id = id;
34+
this.name = name;
35+
}
36+
}

src/main/java/com/code/repository/study/http/HscodeGatherer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public static void main(String[] args){
5252
// // 多线程
5353
ArrayList<Future<List<Map<String, String>>>> results = new ArrayList<Future<List<Map<String, String>>>>();
5454
try{
55-
int start1=1;
56-
for(;start1<=97;start1++) {
57-
int start2=1;
58-
for (; start2 <= 99; start2++) {
55+
int start1=81;
56+
for(;start1<=99;start1++) {
57+
int start2=9;
58+
for (; start2 <= 9; start2++) {
5959
String hscode4 = HscodeGatherer.numToStr(start1)+HscodeGatherer.numToStr(start2);
6060
System.out.println(hscode4);
6161
results.add(executorPool.submit(new HscodeGatherer(hscode4)));
@@ -87,7 +87,7 @@ public static void main(String[] args){
8787

8888

8989
private static String numToStr(int num){
90-
if(num<9){
90+
if(num<=9){
9191
return "0"+num;
9292
}else{
9393
return String.valueOf(num);

0 commit comments

Comments
 (0)