cours-info/Palindrome.java
2019-06-16 16:12:37 +02:00

21 lines
404 B
Java

import static utils.Utils.*;
public class Palindrome {
public static final void main(String[] args) {
testPalindrome(Palindrome::estPalindrome);
}
private static final boolean estPalindrome(char[] mot) {
for (int i=0; i < mot.length/2; i++) {
char c1 = mot[i];
char c2 = mot[mot.length -i-1];
if (c1 != c2) {
return false;
}
}
return true;
}
}