codedamn

Check if String is palindrome or not.

Created by Piyush Garg about a year ago

0

No description provided

1 Comment

    0

    import java.util.Scanner; public class Main {

    public static void main(String args[]) { // Write your code here... Scanner scan = new Scanner(System.in); String q = scan.next(); String s = q.toLowerCase(); boolean isPal = true; int len = s.length(); for(int i = 0;i< len; i++){ if(s.charAt(i) != s.charAt(len-1-i)){ isPal = false; break; } } if(isPal){ System.out.println("A Palindrome"); }else{ System.out.println("Not a Palindrome"); }

    } }

    *For case sensitivity I put some though , I deviced this method which i did't use but fun to make if(Character.toLowerCase(s.charAt(i)) != Character.toLowerCase(s.charAt(len-1-i))) But Instead endup using a whole string for storing lower case character.

    @pranshubasak

    Pranshu Basak

    @pranshubasak

Your comment