Version without JavaScript, read-only: workshops, quizzes and running code are not available here. Full version · Catalogue · Sign in
Sequence
Palindrome
Core exercise
Write estPalindrome(String texte) that returns true if the string reads the same in both directions. Characters are compared as they are (case-sensitive, without ignoring spaces). The empty string is a palindrome.
A workshop goes here: you write and run code in it. It requires JavaScript.
Starting code
Exercices.java
public class Exercices {
public static void main(String[] args) {
System.out.println(estPalindrome("radar"));
System.out.println(estPalindrome("java"));
}
public static boolean estPalindrome(String texte) {
// TODO
return false;
}
}
The core exercise is validated in the workshop, which requires JavaScript.
Hint 1
Two indices moving towards each other: one at the start, one at the end. Or compare charAt(i) with charAt(length - 1 - i) over the first half.