Skip to content

Commit e3e4d20

Browse files
常见格式转换及单测
1 parent 83b4e4b commit e3e4d20

File tree

7 files changed

+104
-1
lines changed

7 files changed

+104
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.base;
2+
3+
import java.math.BigDecimal;
4+
5+
/**
6+
* @Auther: Administrator
7+
* @Date: 2019\9\3 0003 0:24
8+
* @Description:
9+
*/
10+
public class BigDecimalInitTest {
11+
public static void main(String[] args) {
12+
BigDecimal amount1=new BigDecimal("0.06");
13+
BigDecimal amount2=new BigDecimal(0.06);
14+
System.out.println(amount1);
15+
System.out.println(amount2);
16+
}
17+
}
18+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.base;
2+
3+
/**
4+
* @Auther: Administrator
5+
* @Date: 2019\8\27 0027 23:13
6+
* @Description:
7+
*/
8+
public class IntegerDemo2 {
9+
10+
public static void main(String[] args) {
11+
Integer integer1=129;
12+
Integer integer2=129;
13+
14+
if(integer1.intValue()==integer2.intValue()){
15+
System.out.println("test");
16+
}
17+
}
18+
}

src/main/java/com/collection/ListOperation.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.collection;
22

3+
import java.lang.reflect.Array;
4+
import java.util.Arrays;
35
import java.util.Iterator;
46
import java.util.List;
57

@@ -30,4 +32,12 @@ public void ergodicByIterator(List<String> list){
3032
}
3133

3234

35+
public List arraysToList(String[] strArray){
36+
return Arrays.asList(strArray);
37+
}
38+
39+
public Object[] listToArrays(List<String> list){
40+
return list.toArray();
41+
}
42+
3343
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.regex;
2+
3+
/**
4+
* @Auther: Administrator
5+
* @Date: 2019\12\8 0008 16:33
6+
* @Description:
7+
*/
8+
public class ReplaceAllDemo {
9+
public static void main(String[] args) {
10+
String test="123abc45def";
11+
System.out.println(test.replaceAll("\\d+",""));
12+
}
13+
}

src/main/java/com/string/WordsAmount.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class WordsAmount {
1414
public static void main(String[] args) {
1515
String str="apple 1 banana 2pear 23 banana pear pear";
1616
Map wordsMap=countEachWorld(str);
17-
printMap( wordsMap ); ;
17+
printMap( wordsMap );
1818
}
1919
//计算字符串中每一个单词出现的个数
2020
public static Map countWords(String str){
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.collection;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
/**
7+
* @Auther: Administrator
8+
* @Date: 2019\8\13 0013 0:08
9+
* @Description:
10+
*/
11+
public class ArrayListTest {
12+
public static void main(String[] args) {
13+
List list=new ArrayList(100);
14+
}
15+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.json;
2+
3+
import net.sf.json.JSONArray;
4+
import net.sf.json.JSONObject;
5+
6+
/**
7+
* @Auther: Administrator
8+
* @Date: 2019\7\10 0010 23:31
9+
* @Description:
10+
*/
11+
public class JsonTest {
12+
public static void main(String[] args) {
13+
JSONArray jsonArray=new JSONArray();
14+
JSONObject jsonObject=new JSONObject();
15+
jsonObject.put("name","lin");
16+
jsonObject.put("age",100);
17+
jsonArray.add(jsonObject);
18+
// for(int i=0;i<jsonArray.size();i++){
19+
// JSONObject jsonobject=jsonArray.getJSONObject(i);
20+
// System.out.println(jsonobject.getString("name"));
21+
// }
22+
for (Object user:jsonArray){
23+
String name= ((JSONObject) user).getString("name");
24+
System.out.println(name);
25+
}
26+
27+
28+
}
29+
}

0 commit comments

Comments
 (0)