-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution005Test.java
More file actions
43 lines (32 loc) · 1.44 KB
/
Solution005Test.java
File metadata and controls
43 lines (32 loc) · 1.44 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
package com.portgas;
import org.junit.Test;
public class Solution005Test {
@Test
public void test() {
String str1 = "A B";
String str2 = "";
String str3 = " AB ";
String result1 = new Solution005().replaceSpace(new StringBuffer(str1));
String result2 = new Solution005().replaceSpace(new StringBuffer(str2));
String result3 = new Solution005().replaceSpace(new StringBuffer(str3));
System.out.println("result1 = " + result1
+ "\nresult2 = " + result2
+ "\nresult3 = " + result3);
String result4 = new Solution005().replaceSpace2(new StringBuffer(str1));
String result5 = new Solution005().replaceSpace2(new StringBuffer(str2));
String result6 = new Solution005().replaceSpace2(new StringBuffer(str3));
System.out.println("result4 = " + result4
+ "\nresult5 = " + result5
+ "\nresult6 = " + result6);
long time1 = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
new Solution005().replaceSpace(new StringBuffer(str1));
}
System.out.println("time1 = " + (System.currentTimeMillis() - time1));
long time2 = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
new Solution005().replaceSpace2(new StringBuffer(str1));
}
System.out.println("time2 = " + (System.currentTimeMillis() - time2));
}
}