Skip to content

Commit 644ecbd

Browse files
mansi2392pedja4
authored andcommitted
BAEL-1090 Difference between Compressed String and Compact String in Java 9 (eugenp#2574)
* Example Code For Evaluation Article This is an example code for the evaluation article on "Different Types of Bean Injection in Spring" * Added unit tests * Minor changes to application context * Removed code committed for evaluation article * BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5 * BAEL-944 Demonstrating the problems with new Url pattern matching in Spring 5 * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Exploring the Spring MVC URL Matching Improvements * BAEL-944 Code Formatting and solving build issue * BAEL-944 Resolving build issue due to change in Spring version * BAEL-944 Resolving build issue * BAEL-944 Formatting code * BAEL-944 Moving tests to correct package * BAEL-944 Moving tests to correct package * BAEL-944 Replacing @RequestMapping by @GetMapping * BAEL-944 Remove unnecessary attribute name, "value" in annotations * BAEL-79 Intro to Activiti with Spring * BAEL-79 Intro to Activiti with Spring * BAEL-79 Adding activiti module to the parent modules * BAEL-79 Using latest version * BAEL-79 Update Spring boot version that works with Activiti * BAEL-79 Replace RequestMapping with GetMapping * BAEL-79 Use Java 8 Syntax * BAEL-79 Formatting * BAEL-79 changed module name * BAEL-378 A Guide to Activiti with Java * BAEL-79 Fixed unit tests * BAEL-79 Simplified the process * BAEL-79 Fix test cases * BAEL-1045 Lambda Behave * BAEL-1045 Lambda Behave * BAEL-1045 Lambda Behave * BAEL-1090 Difference between compact and compressed strings in Java 9
1 parent cccd6a3 commit 644ecbd

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.baeldung.java9.compactstring;
2+
3+
import java.util.List;
4+
import static java.util.stream.Collectors.toList;
5+
import java.util.stream.IntStream;
6+
7+
public class CompactStringDemo {
8+
9+
public static void main(String[] args) {
10+
long startTime = System.currentTimeMillis();
11+
List strings = IntStream.rangeClosed(1, 10_000_000)
12+
.mapToObj(Integer::toString).collect(toList());
13+
long totalTime = System.currentTimeMillis() - startTime;
14+
System.out.println("Generated " + strings.size() + " strings in "
15+
+ totalTime + " ms.");
16+
17+
startTime = System.currentTimeMillis();
18+
String appended = (String) strings.stream().limit(100_000)
19+
.reduce("", (left, right) -> left.toString() + right.toString());
20+
totalTime = System.currentTimeMillis() - totalTime;
21+
System.out.println("Created string of length " + appended.length()
22+
+ " in " + totalTime + " ms.");
23+
}
24+
}

0 commit comments

Comments
 (0)