Java String Tutorial
Java String Tutorial
String literals are always created in String Constant Pool for performance reasons.
In the following example, there will be 3 separate instances of String with same value in
heap memory.
3. Conversions
Convert Java String to int
Convert int to String in Java
Convert String to Long
Convert Long to String in Java
Convert String to Date
Convert Date to String
Convert String to String[] Example
Java 8 – Join String Array – Convert Array to String
Convert String to InputStream Example
Convert InputStream to String Example
Java Split CSV String – Convert String to List Example
Join CSV to String
Unescape HTML to String Example
Escape HTML – Encode String to HTML Example
Convert byte array to String
StackTrace to String conversion
Convert float to String – Format to N decimal points
4. Useful Examples
Reverse a String in Java using Recursion
Remove extra white spaces between words
Remove only leading spaces of a String
Remove only trailing spaces of a String
How to Reverse String in Java
Reverse words in a string in Java
Reverse string in Java using recursion
How to find duplicate words in String
How to find duplicate characters in a String
Java Sort String Characters Alphabetically
Convert String to Title Case
4 ways to split a String
Left, right, or center align string
Read File to String
Java 8 StringJoiner Example
Left pad a string with spaces or zeros
Right pad a string with spaces or zeros
Get first 4 characters of a string
Get last 4 characters of a string
Mask a String Except Last 4 Chars
Format string to (123) 456-7890 pattern
Removing Last Character from String
5. FAQs
Why String is immutable
Java String Interview Questions