Skip to content

Commit 02a4187

Browse files
author
xoften
committed
sda
1 parent 9a76b26 commit 02a4187

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/mj223gn_assign4/StringConcatenations.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ public static void main(String[] args) {
1414
}
1515

1616
public static void shortConcatenation() {
17-
String out = "";
18-
final long start = System.nanoTime();
19-
for (int j = 0; j < 35000; j++) {
20-
out += "y";
17+
String out = "";
18+
final long start = System.nanoTime();
19+
for (int j = 0; j < 35000; j++) {
20+
out += "y";
21+
}
22+
final long end = System.nanoTime();
23+
System.out.println("Time is: " + (end - start) / 1000000 + " ms");
24+
System.out.println("Number of chars in string: " + out.length());
25+
System.out.println("Number of iterations: " + out.length());
2126
}
22-
final long end = System.nanoTime();
23-
System.out.println("Time is: " + (end - start) / 1000000 + " ms");
24-
System.out.println("Number of chars in string: " + out.length());
25-
System.out.println("Number of iterations: "+ out.length());
26-
}
2727

2828
public static void longConcatenation() {
2929
String out = "";

0 commit comments

Comments
 (0)