Java String Tutorials: Become a Java Strings Virtuoso
A deep dive into the world of Java strings, with special attention to Java 8 string tutorials, plus a foray into Java string tutorials for Java 9 and one.
Join the DZone community and get the full member experience.
Join For FreeIntro to Java Strings

String Memory Internals by Tomasz Murkiewicz. The main point to understand here is the distinction between String Java object and its contents -
char[]
under private value field. String is basically a wrapper aroundchar[]
array, encapsulating it and making it impossible to modify so the String can remain immutable. Also the String class remembers which parts of this array is actually used. This all means that you can have two different String objects (quite lightweight) pointing to the samechar[]
.Top 10 Questions of Java Strings by Ryan Wang. A discussion of ten common questions Java developers face when working with Strings. Though this is a bit of an old post (published in 2013), we hope you'll still find some value in these lessons.
Java 8 String Tutorials

Java String Format Examples by Jay Sridhar. This tutorial offers a brief overview, several examples, and a collection of references to keep by your side whenever you are formatting Java strings.
How to Convert an Array to String in Java [Snippet] by Ramesh Fadatare. In this quick article, we’re going to look at different ways to convert an array of strings or integers to a string.
Convert a List to a Comma-Separated String in Java 8 by Mario Pio Gioiosa. This tutorial demonstrates how to use streams in Java 8 and Java 7 to convert a list to a comma-separated string by manipulating the string before joining.
Concatenating Strings in Java 8 by Daniela Kolarova. Brush up on your string concatenation skills with this look at what Java 8 brought, including working with streams and Optionals, as well as general advice.
Two Ways to Join Strings in Java 8 StringJoiner and String.join Examples by Javin Paul. Check out this post to learn more about the two different ways you can join a String in Java 8 — without using a third-party library!
Joining Strings in JDK 8 by Dustin Marx. JDK 8 introduced language features such as lambda expressions, streams, and even the new Date/Time API that changed the way we write Java applications. However, there were also several new APIs and features that might gave beeb less "game changing," but still brought greater convenience and expressiveness to the Java programming language. In this post, we look at one of these smaller features and examine the ability to easily concatenate multiple Strings in JDK 8.
The Do's and Don'ts of Java Strings by Lyndsey Padget. Here are best practices for Java Strings for aspects of coding including i18m, l10n, concatenation, building huge strings, string equality, and comparators.
Java 8 Optional Usage and Best Practices by Hopwell Mutanda. Check out this post where we look at Optional, first introduced in Java 8, how to use it with strings, and best practices for implementing it in your existing projects.
String Representation of Java Decimals Without Scientific Notation by Dustin Marx. Learn how to print your decimal numbers in Java as full strings while skipping the scientific notation for cleaner, more readable outputs.
A Clarified String Formatting Cheatsheet by Alex Theedom. Good to keep close by, this simplified guide to String formatting in Java covers numbers, the available flags, and handling multiple arguments.
We Don't Need StringBuilder for Simple Concatenation by A.N.M. Bazlur Rahman. Concatenating strings is useful, but expensive. Fortunately, you don't need to use StringBuilder anymore - the compiler can handle it for you.
Duplicate Strings: How to Get Rid of Them and Save Memory by Misha Dmitriev. In this performance tutorial, you'll learn why duplicate stings emerge in Java applications and how you can detect and remove them to avoid memory problems.
Java 8 Java.Time Package: Parsing Any String to Date [Code Snippets] by Michael Gantman. Check out this short post on parsing Java Strings into date and time formats. While we don't cover all possible formats, we do look at a good set to start with!
String Interning — What , Why, and When? by Saurabh Chhajed. Learn about string interning, a method of storing only one copy of each distinct immutable string value, and how it's used to improve performance in Java.
UseStringDeduplication: Pros and Cons by Ram Lakshmanan. In this post, we assess the causes of duplicate strings in Java applications, as well as implementing the UseStringDeduplication method and its pros and cons.
Java String Tutorials: Java 9 and Up

Compact Strings in Java 9 by Mahmoud Anouti. Explore Java 9's compact strings, including their positive impact on garbage collection and app performance, how to enable them, and how to use them.
JDK 9/10/11: Side Effects From += on Java String by Dustin Marx. In this quick post, we take a look at a peculiar bug present in JDKs 9, 10, and 11 involving how the Java compiler interprets += on Java Strings.
JDK/JEP 280: String Concatentations Will Never Be the Same by Dustin Marx. Since JDK 9, string concatenations have undergone a significant change. Come find out the what and the how in this post with code examples.
Reverse String Alternatives in Java [Snippets] by Talwinder Singh. Check out these example code snippets to learn more about the various ways inwich you can implement a reverse String in your Java code.
New Methods on Java Strings With JDK 11 by Dustin Marx. JDK 11 will probably be bringing a few new methods to the String class! Most of them focus on redefining white space for a more consistent approach.
Java 11 String API Updates by Grzegorz Piwowarek. This post takes a look at some of the new API features presented in the JDK 11 release, specifically the String API and what this means for your next project.
Applying New JDK 11 String Methods by Dustin Marx. A tutorial demonstrates how to use six new String methods in JDK11, including sample code and instructions that will make tasks related to Java Strings easier.
Moving to Java 11: Rediscover Some Gems You Might Have Missed by Andrea Del Bene. In this article, we attempted to summarize the most useful API enhancements introduced since Java 8, including the I/O Stream, class Files, and Path.
The Right Way to Reverse a String in Java by Jonatan Ivanov. Usually, not writing code to solve problems is a good idea — reverse a String using this simpler implementation than more common approaches.
Java 12 String API Updates by Grzegorz Piwowarek. This post explores the newest feature updates to string APIs in Java 12, String#indent(int), String#transform(function), String#describeConstable, and more.
JDK 12: Raw Stirng Literals by Hemambara Vamsi Kotari. This post introduces the upcoming changes to raw string literals in JDK 12, highlighting multi-line strings when compared to earlier releases and more.
The Brief Yet Complicated History of JDK 12's String::transform Method by Dustin Marx. JDK 12 has already seen some turmoil with respect to the String class. We focus on one method and see if it will stay or if it could be on the chopping block.
Java 13 Refcard by Simon Ritter. A Java expert goes everting Java developers need to know about the new JDK 13, walking through code examples to illustrate these new updates and the benefits they bring. Including Java Strings!
Duplicate Objects in Java: Not Just Strings by Misha Dmitriev. In this post, we take a closer look at duplicate objects in Java and how they not only impact strings but other classes as well, including arrays.
Decide if a String Has Duplicates by Zoltan Raffai. Check out this post to learn more about strings in Java and how you can determine if a string has duplicates in your Java code.
Opinions expressed by DZone contributors are their own.
Comments