Free Academic Seminars And Projects Reports
PROGRAM TO CHECK WHETHER THE STRINGS ARE PALINDROME OR NOT - Printable Version

+- Free Academic Seminars And Projects Reports (https://easyreport.in)
+-- Forum: Academic (https://easyreport.in/forumdisplay.php?fid=41)
+--- Forum: Study guide (https://easyreport.in/forumdisplay.php?fid=63)
+---- Forum: Technical (https://easyreport.in/forumdisplay.php?fid=64)
+---- Thread: PROGRAM TO CHECK WHETHER THE STRINGS ARE PALINDROME OR NOT (/showthread.php?tid=57468)



PROGRAM TO CHECK WHETHER THE STRINGS ARE PALINDROME OR NOT - risvan - 10-04-2017

Code:
import java.io.*;
class Dem20
{
  public static void main(String args[])throws IOException
{
  BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
  int i,n=0;
  String s1;
try
  {
  System.out.println("enter the size of array:");

  n=Integer.parseInt(b.readLine());
  String s=new String[n];
  System.out.println("enter the string:");
  for(i=0;i<n;i++)
  {
  s[i]=b.readLine();
  }
  for(i=0;i<n;i++)
  {
  StringBuffer sb=new StringBuffer(s[i]) ;
  s1=new String(sb.reverse());
  if(s[i].equals(s1))
  {
  System.out.println("String is"+s[i]+""+"palindrome");
  }
  else
  {
  System.out.println("String is"+s[i]+""+"not palindrome");
  }
  }

  }
  catch(Exception e)
  {
  System.out.println(e);
  }
  }
}

OUTPUT
E:\3msc\java\meenu>java Dem20
enter the size of array:
3
enter the string:
aba
joby
jiss
String is aba palindrome
String is joby not palindrome
String is jiss snot palindrome