cours-info/Palindrome.java

21 lines
404 B
Java
Raw Normal View History

2019-06-16 14:04:53 +00:00
import static utils.Utils.*;
public class Palindrome {
public static final void main(String[] args) {
testPalindrome(Palindrome::estPalindrome);
}
private static final boolean estPalindrome(char[] mot) {
2019-06-16 14:09:17 +00:00
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;
2019-06-16 14:04:53 +00:00
}
}