Lesson 22 of 34

String Problems: Reverse, Palindrome, Count

10 min 30 XP

Loop over a String character by character with charAt(i) or toCharArray(). Reversing, palindromes and counting vowels are campus-interview favourites.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Character.isDigit(ch), Character.isLetter(ch) and Character.isUpperCase(ch) tell you what kind of character you have.

Challenge

+30 XP

Read a word. Print "Palindrome" if it reads the same backwards, otherwise "Not palindrome". Ignore capital letters (Madam is a palindrome).

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.