String is a sequence of characters. For example, "Hello World"
is a string.
Java supports strings via String class. It provides constructors to create strings, and methods to perform functions on them.
Java String Tutorials
In the following tutorials, we will learn how to create strings, read strings, print strings to console, and transform them, etc.
Basics
- Java – Print a String to Console Output
- Java – Read a String from Console Input
- Java – Create String from Char Array
- Java – Create String from Byte Array
- Java – Concatenate Two Strings
- Java – Get the Index of the First Occurrence of a Substring in a String
- Java – Get the Index of nth Occurrence of a Substring in a String
Checks
- Java – Check if Two Strings are Equal
- Java – Check if a String Ends with Specified Suffix String
- Java – Check if a String Starts with Specified Prefix String
- Java – Check if a String is Blank
- Java – Check if a String is Empty
- Java – Check if a String contains Specific String
- Java – Validate if String is a Phone Number
Character Level
- Java – Get Character at Specified Index from String
- Java – Get First Character from String
- Java – Get Last Character from String
Transformations
- Java – Replace First Occurrence of a Substring in a String
- Java – Replace All Occurrences of a Substring in a String
- Java – Join Two or More Strings with Delimiter
- Java – Join Elements of String Array with Delimiter
- Java – Join Elements of ArrayList<String> with Delimiter
- Java – Reverse a string
- Java – Trim String
- Java – Split String
- Java – Remove White Spaces in the String
- Java – Replace Multiple Spaces with Single Space
Comparisons
- Java – Compare two Strings Lexicographically
- Java – Compare String and CharSequence
- Java – Compare String and StringBuffer
Conclusion
In this Java Tutorial, we learned about Strings and different operations with Strings in Java.