Master fundamental Java concepts with these beginner-friendly programs
A program to reverse a given string.
Write a program to reverse a given string.
"hello"
Reversed string: olleh
A program to check whether a given string is a palindrome.
Write a program to check whether a given string is a palindrome.
"madam"
madam is a Palindrome
A program to reverse a given string.
Write a program to reverse a given string.
"hello"
Reversed string: olleh
A program to check whether a given string is a palindrome.
Write a program to check whether a given string is a palindrome.
"madam"
madam is a Palindrome
A program to count vowels and consonants in a string.
Write a program to count the number of vowels and consonants in a string.
"programming"
Vowels: 3
Consonants: 8
A program to convert a string to uppercase and lowercase.
Write a program to convert a string to uppercase and lowercase.
"Java Programming"
Uppercase: JAVA PROGRAMMING
Lowercase: java programming
A program to find the length of a string without using .length().
Write a program to find the length of a string without using .length().
"hello"
Length of the string: 5
A program to count the number of words in a sentence.
Write a program to count the number of words in a sentence.
"Java is fun"
Number of words: 3
A program to check if two strings are anagrams.
Write a program to check if two strings are anagrams (contain the same characters in different order).
"listen", "silent"
The strings are anagrams
A program to remove duplicate characters from a string.
Write a program to remove duplicate characters from a string.
"programming"
String after removing duplicates: progamin
A program to find the most frequent character in a string.
Write a program to find the character that appears most frequently in a string.
"banana"
Most frequent character: a
A program to swap the first and last characters of a string.
Write a program to swap the first and last character of a string.
"hello"
Swapped string: oellh
A program to check if a string contains only numeric digits.
Write a program to check if a given string contains only numeric digits.
"12345"
The string contains only digits.
\d+ to check for digit-only content.A program to count the occurrences of a character in a string.
Write a program to count how many times a given character appears in a string.
"banana", 'a'
Character 'a' appears 3 times.
A program to find the first non-repeating character in a string.
Write a program to find the first non-repeating character in a string.
"swiss"
First non-repeating character: w
A program to check if one string is a rotation of another.
Write a program to check if one string is a rotation of another.
"hello", "lohel"
The strings are rotations of each other.
A program to remove all spaces from a given string.
Write a program to remove all spaces from a given string.
"Java Programming"
JavaProgramming
A program to check if a string contains every letter of the alphabet at least once.
Write a program to check if a string contains every letter of the alphabet at least once.
"The quick brown fox jumps over the lazy dog"
The string is a pangram.
A program to replace a specific word in a sentence.
Write a program to replace a specific word in a sentence.
"Java is fun", replace "fun" with "awesome"
Java is awesome
A program to find the longest word in a given sentence.
Write a program to find the longest word in a given sentence.
"I love programming"
Longest word: programming
A program to convert a given string into a character array and print each character.
Write a program to convert a given string into a character array and print each character.
"hello"
h e l l o
A program to check whether a given string is a valid email address.
Write a program to check whether a given string is a valid email address.
"example@email.com"
Valid