forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move articles out of java-strings part5
- Loading branch information
1 parent
de6e81b
commit a15d1ef
Showing
56 changed files
with
212 additions
and
693 deletions.
There are no files selected for viewing
9 changes: 3 additions & 6 deletions
9
...a/com/baeldung/string/StringUnitTest.java → ...om/baeldung/stringapi/StringUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
## Java Strings | ||
|
||
This module contains articles about strings in Java. | ||
|
||
### Relevant Articles: | ||
- [Use char[] Array over a String for Manipulating Passwords in Java?](https://www.baeldung.com/java-storing-passwords) | ||
- [Compact Strings in Java 9](https://www.baeldung.com/java-9-compact-string) | ||
- [String Not Empty Test Assertions in Java](https://www.baeldung.com/java-assert-string-not-empty) | ||
- [String Performance Hints](https://www.baeldung.com/java-string-performance) | ||
- [Java Localization – Formatting Messages](https://www.baeldung.com/java-localization-messages-formatting) | ||
- [Java – Generate Random String](https://www.baeldung.com/java-random-string) | ||
- [Java String Interview Questions and Answers](https://www.baeldung.com/java-string-interview-questions) | ||
- [Java Multi-line String](https://www.baeldung.com/java-multiline-string) | ||
- [Guide to Java String Pool](https://www.baeldung.com/java-string-pool) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>core-java-strings</artifactId> | ||
<version>0.1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
<name>core-java-strings</name> | ||
|
||
<parent> | ||
<groupId>com.baeldung</groupId> | ||
<artifactId>parent-java</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<relativePath>../../parent-java</relativePath> | ||
</parent> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-lang3</artifactId> | ||
<version>${commons-lang3.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-core</artifactId> | ||
<version>${jmh-core.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-generator-annprocess</artifactId> | ||
<version>${jmh-generator.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.ibm.icu</groupId> | ||
<artifactId>icu4j</artifactId> | ||
<version>${icu4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>${assertj.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>core-java-strings</finalName> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
<properties> | ||
<assertj.version>3.6.1</assertj.version> | ||
<icu4j.version>61.1</icu4j.version> | ||
</properties> | ||
|
||
</project> |
7 changes: 4 additions & 3 deletions
7
...ava9/compactstring/CompactStringDemo.java → ...ava9/compactstring/CompactStringDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
package com.baeldung.java9.compactstring; | ||
|
||
import java.util.List; | ||
import static java.util.stream.Collectors.toList; | ||
import java.util.stream.IntStream; | ||
|
||
import static java.util.stream.Collectors.toList; | ||
|
||
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 " | ||
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() | ||
System.out.println("Created string of length " + appended.length() | ||
+ " in " + totalTime + " ms."); | ||
} | ||
} |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
.../com/baeldung/localization/ICUFormat.java → .../com/baeldung/localization/ICUFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...ung/string/multiline/MultiLineString.java → ...m/baeldung/multiline/MultiLineString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...om/baeldung/string/StringPerformance.java → .../stringperformance/StringPerformance.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 4 additions & 3 deletions
7
...dung/string/interview/LocaleUnitTest.java → ...om/baeldung/interview/LocaleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ring/interview/StringAnagramUnitTest.java → ...dung/interview/StringAnagramUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...g/interview/StringChangeCaseUnitTest.java → ...g/interview/StringChangeCaseUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...rview/StringCountOccurrencesUnitTest.java → ...rview/StringCountOccurrencesUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...tring/interview/StringFormatUnitTest.java → ...ldung/interview/StringFormatUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...tring/interview/StringInternUnitTest.java → ...ldung/interview/StringInternUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
...tring/interview/StringJoinerUnitTest.java → ...ldung/interview/StringJoinerUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...g/interview/StringPalindromeUnitTest.java → ...g/interview/StringPalindromeUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ring/interview/StringReverseUnitTest.java → ...dung/interview/StringReverseUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...string/interview/StringSplitUnitTest.java → ...eldung/interview/StringSplitUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../interview/StringToByteArrayUnitTest.java → .../interview/StringToByteArrayUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
.../interview/StringToCharArrayUnitTest.java → .../interview/StringToCharArrayUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...ng/interview/StringToIntegerUnitTest.java → ...ng/interview/StringToIntegerUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
...ldung/localization/ICUFormatUnitTest.java → ...ldung/localization/ICUFormatUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...ng/multiline/MultiLineStringUnitTest.java → ...ng/multiline/MultiLineStringUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.