Question d’entretien chez ServiceNow

Write a program to find whether a given string is palindrome or not?

Réponse à la question d'entretien

Utilisateur anonyme

18 déc. 2015

You just have to create new String variable where you add the characters from right to left (reverse order) one by one and compare it to the original String. If they are both the same, then return true. This is the Java implementation: public static boolean palindrome(String a){ String reverse =""; for(int i = a.length(); i > 0; i--){ reverse = reverse + a.substring(i-1,i); } if(reverse.equals(a)) return true; return false; }