BEST PROGRAM FOR STRING PALINDROME IN JAVA
/* The progrma will check whether a word is palindrome.
* BEST PROGRAM FOR STRIG PALINDROME IN JAVA */
package advance;
import javax.swing.*;
public class Palindrom {
public static boolean ispalindrom(String str) {
int i = 0, j = str.length();
while ((i < j) && (str.charAt(i++) != str.charAt(--j))) {
return false;
}
return true;
}
public static void main(String[] args) {
String str = JOptionPane.showInputDialog("Enter a string");
if(ispalindrom(str))
JOptionPane.showMessageDialog(null, str + " is a Palindrome String.");
else
JOptionPane.showMessageDialog(null, str + " is a not a Palindrome String.");
}
}