Palindrome Strings are that strings which have same word if we change their character in reverse order . So it does'n matter if we reverse them ,their word remain same .
Source Code
package com.ancodingpoint.www; import java.util.Scanner; public class Palindrome{ public static void main(String[] args) { Scanner input = new Scanner (System.in); String user_story = ""; String pal_string = ""; int length ; System.out.println(" Enter Your Stroy to Check its Palindrome "); user_story = input.nextLine(); length = user_story.length(); for (int i = length-1;i>=0;i--) pal_string = pal_string + user_story.charAt(i); if (user_story.equals(pal_string)) System.out.println(" Your Story is Palindrome "); else System.out.println(" Your Story is Not Palindrome "); } }
0 comments:
Post a Comment