Write a java program using method Palin(), to check whether a string is palindrome or not.
and those who know java they only answer plz guys its a request. plz plz plz
Answers
// Java program to illustrate checking of a string
// if its palindrome or not using reverse function
class Palindrome
{
public static void checkPalindrome(String s)
{
// reverse the given String
String reverse = new StringBuffer(s).reverse().toString();
// check whether the string is palindrome or not
if (s.equals(reverse))
System.out.println("Yes");
else
System.out.println("No");
}
public static void main (String[] args)
throws java.lang.Exception
{
checkPalindrome("malayalam");
checkPalindrome("GeeksforGeeks");
}
}
Output:
Yes
No
Answer:
Explanation:
Examples:
Input : malayalam
Output : Yes
Input : GeeksforGeeks
Output : No
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
filter_none
edit
play_arrow
brightness_4
// Java program to illustrate checking of a string
// if its palindrome or not using reverse function
class Palindrome
{
public static void checkPalindrome(String s)
{
// reverse the given String
String reverse = new StringBuffer(s).reverse().toString();
// check whether the string is palindrome or not
if (s.equals(reverse))
System.out.println("Yes");
else
System.out.println("No");
}
public static void main (String[] args)
throws java.lang.Exception
{
checkPalindrome("malayalam");
checkPalindrome("GeeksforGeeks");
}
}
Output:
Yes
No
Related Article :
C program to check whether a given string is palindrome or not
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.