Practice Strings in Java

String manipulation, pattern matching, and text processing in Java.

Work through 19 exercises with starter code, expected output, test cases, and hints.

Strings exercises

  1. String Length Java exercise — Find the length of a string
  2. Convert to Uppercase Java exercise — Convert a string to uppercase
  3. Character at Index Java exercise — Get character at a specific position
  4. Extract Substring Java exercise — Extract a portion of a string
  5. Check Contains Java exercise — Check if a string contains a substring
  6. Replace Characters Java exercise — Replace parts of a string
  7. Reverse String Java exercise — Reverse a string
  8. String Palindrome Java exercise — Check if a string is a palindrome
  9. Count Vowels Java exercise — Count vowels in a string
  10. Count Words Java exercise — Count words in a sentence
  11. First Non-Repeating Character Java exercise — Find the first character that does not repeat
  12. Anagram Check Java exercise — Check if two strings are anagrams
  13. Longest Word Java exercise — Find the longest word in a sentence
  14. Remove All Spaces Java exercise — Remove all whitespace from a string
  15. Character Frequency Java exercise — Count frequency of each character
  16. String Compression Java exercise — Compress string using counts of repeated characters
  17. Alphabetical Character Frequency Java exercise — Count frequency of each character
  18. Remove Adjacent Duplicates Java exercise — Remove adjacent duplicate characters
  19. Zigzag Conversion Java exercise — Convert string to zigzag pattern

Browse the complete Java practice path · Open the online Java compiler