Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Palindrome {
- static String ss;
- int x = 0;
- static char first = ss.charAt(0);
- static char last = ss.charAt(ss.length());
- static int length;
- public static void main(String[] args) {
- System.out.println("Enter a word or phrase, to test whether it is a palindrome: ");
- Scanner keyboard = new Scanner(System.in);;
- String s = keyboard.nextLine();
- String ss = s.toLowerCase();
- if (isPalindrome){
- System.out.println("\"" s "\" is a palindrome.");
- }
- else{
- System.out.println("\"" s "\" is not a palindrome.");
- }
- }
- public static boolean isPalindrome(String ss) {
- length = ss.length();
- int x = 0;
- ss.substring (x, ss.length()-x);
- if (first == last){
- x++;
- return true;
- }
- else
- {
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement