[BAEL-8232] - Moved java string related code and github links into new module java-strings
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
- [Java 9 Reactive Streams](http://www.baeldung.com/java-9-reactive-streams)
|
||||
- [How to Get All Dates Between Two Dates?](http://www.baeldung.com/java-between-dates)
|
||||
- [Java 9 java.util.Objects Additions](http://www.baeldung.com/java-9-objects-new)
|
||||
- [Compact Strings in Java 9](http://www.baeldung.com/java-9-compact-string)
|
||||
- [Convert Date to LocalDate or LocalDateTime and Back](http://www.baeldung.com/java-date-to-localdate-and-localdatetime)
|
||||
- [Java 9 Variable Handles Demistyfied](http://www.baeldung.com/java-variable-handles)
|
||||
- [Exploring the New HTTP Client in Java 9](http://www.baeldung.com/java-9-http-client)
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
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() - startTime;
|
||||
System.out.println("Created string of length " + appended.length()
|
||||
+ " in " + totalTime + " ms.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user