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
The following tutorials cover basic concepts of strings like creating string values, printing string value, string concatenation, etc.
- Java – Create an empty string
- Java – Initialize string
- 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 strings
Find Operations
- Java – Find index of substring in a string
- Java – Find index of nth occurrence of a substring in a string
Checks
- Java – Check if strings are equal
- Java – Check if strings are equal ignoring case
- Java – Check if string ends with specific value
- Java – Check if string starts with specific value
- Java – Check if string is blank
- Java – Check if string is empty
- Java – Check if string contains specific substring
- Java – Validate if string is a phone number
Character Level
- Java – Get character at specified index in string
- Java – Get first character from string
- Java – Get last character from string
- Java – Iterate over characters in string
- Java – Get unique characters in string
- Java – Convert string to char array
- Java – Remove first character in string
- Java – Remove last character in string
Transformations
- Java – Convert string to uppercase
- Java – Convert string to lowercase
- Java – Repeat string for N times
- Java – Replace substring in a string
- Java – Replace all occurrences of substring in 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 strings
- 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.