Given String is Palindrome or not
Do you like this story?
import javax.swing.JOptionPane;
import java.io.*;
class Pallindrome1
{
public static void main(String[] args) throws IOException
{
String str;
int flag=0;
str=JOptionPane.showInputDialog("enter a string");
int len=str.length()-1;
for(int i=0;i
{
if(str.charAt(i)!=str.charAt(len))
flag=1;
}
if(flag==0)
JOptionPane.showMessageDialog(null,"it is a pallindrome","Message",JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null,"it is not a pallindrome","Message",JOptionPane.INFORMATION_MESSAGE);
}
}
import java.io.*;
class Pallindrome1
{
public static void main(String[] args) throws IOException
{
String str;
int flag=0;
str=JOptionPane.showInputDialog("enter a string");
int len=str.length()-1;
for(int i=0;i
{
if(str.charAt(i)!=str.charAt(len))
flag=1;
}
if(flag==0)
JOptionPane.showMessageDialog(null,"it is a pallindrome","Message",JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null,"it is not a pallindrome","Message",JOptionPane.INFORMATION_MESSAGE);
}
}

This post was written by: Rajendra Prasad
Rajendra Prasad is a professional blogger, web designer and front end web developer. Follow him on Facebook