Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Palindrome {
- public static void main(String[] args){
- String pal = "racecar";
- char[] palch = pal.toCharArray();
- System.out.println(isPal(palch, 0));
- }
- static boolean isPal (char[] palch, int n){
- System.out.println(palch[n] + " " + palch[palch.length-1-n)]);
- if (palch.length <= 1){
- return true;
- }
- if (palch[n] != palch[palch.length-n-1)]){
- return false;
- }
- return isPal(palch, n++);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement