Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. class Palindrome {
  2. public static void main(String[] args){
  3. String pal = "racecar";
  4. char[] palch = pal.toCharArray();
  5. System.out.println(isPal(palch, 0));
  6.  
  7. }
  8.  
  9. static boolean isPal (char[] palch, int n){
  10. System.out.println(palch[n] + " " + palch[palch.length-1-n)]);
  11. if (palch.length <= 1){
  12. return true;
  13. }
  14. if (palch[n] != palch[palch.length-n-1)]){
  15. return false;
  16. }
  17. return isPal(palch, n++);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement