Module 4: String Programs
Java string manipulation programs covering reversal, searching, counting, validation, and transformations.
25 program solutions
Program Solutions
Reverse String
Reverse a given string using a loop.
Check Palindrome String
Check whether a string is a palindrome.
Count Vowels
Count the number of vowels in a string.
Count Consonants
Count the number of consonants in a string.
Count Words
Count the number of words in a sentence.
Remove Whitespace
Remove all whitespace characters from a string.
Remove Duplicate Characters
Remove duplicate characters from a string, keeping first occurrences.
Anagram Check
Check whether two strings are anagrams of each other.
String Rotation
Check if one string is rotation of another.
Frequency of Characters
Count frequency of each character in a string.
Longest Word
Find the longest word in a sentence.
Shortest Word
Find the shortest word in a sentence.
Replace Substring
Replace all occurrences of a substring in a string.
Reverse Words in Sentence
Reverse the order of words in a sentence.
Sort Characters
Sort characters of a string in ascending order.
Convert to Title Case
Convert a sentence to title case (first letter of each word uppercase).
Count Uppercase Letters
Count number of uppercase letters in a string.
Count Lowercase Letters
Count number of lowercase letters in a string.
Extract Numbers
Extract all numbers (digits) from a string.
Validate Email (Regex)
Validate email format using a simple regex.
Validate Password
Check if a password meets basic strength rules using regex.
Check Pangram
Check whether a sentence is a pangram (contains all letters A–Z).
Split & Join Strings
Split a sentence into words and then join them with a different delimiter.
String Compression
Compress a string as character followed by count (basic run-length encoding).
String Permutations
Generate all permutations of a string using recursion.