Java Program to Check the String is Palindrome(using StringBuffer)

In this blog we will learn how to check the string whether it is a palindrome or not using string buffer.


import java.util.Scanner;
public class Task_Palindrome1 
private static StringBuffer s1=new StringBuffer();
 public static boolean check(StringBuffer s2)
 {  StringBuffer s3=new StringBuffer(s2);
 String s5= s2.toString();
 String s4= s3.toString();
 int a=s5.compareTo(s4); 
              return true;
            return false;            
    public static void main(String[] args)
        Scanner sc=new Scanner(;
        System.out.println("Enter a string to check Palindrome ");
       // System.out.println(s1);
        boolean a=check(s1);
        System.out.println("Palindrome"+" "+a);

Happy Coding!

Follow us on Instagram @programmersdoor

Join us on Telegram @programmersdoor

Please write comments if you find any bug in above code/algorithm, or find other ways to solve the same problem.

Follow Programmers Door for more.

#blog #interview #placement #learn #computer #science

23 views0 comments

Recent Posts

See All

        Contact Us

  • LinkedIn
  • Facebook
  • Instagram

©2023 by Programmers Door