BAEL-1090 Difference between Compressed String and Compact String in Java 9 (#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
This commit is contained in:
Mansi 2017-09-09 03:29:23 +05:30 committed by Predrag Maric
parent cccd6a3eab
commit 644ecbd0eb
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
package com.baeldung.java9.compactstring;
import java.util.List;
import static java.util.stream.Collectors.toList;
import java.util.stream.IntStream;
public class CompactStringDemo {
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
List strings = IntStream.rangeClosed(1, 10_000_000)
.mapToObj(Integer::toString).collect(toList());
long totalTime = System.currentTimeMillis() - startTime;
System.out.println("Generated " + strings.size() + " strings in "
+ totalTime + " ms.");
startTime = System.currentTimeMillis();
String appended = (String) strings.stream().limit(100_000)
.reduce("", (left, right) -> left.toString() + right.toString());
totalTime = System.currentTimeMillis() - totalTime;
System.out.println("Created string of length " + appended.length()
+ " in " + totalTime + " ms.");
}
}