Import Java
Import Java
BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public Palindrom(){
this.pal="";
}
return true;
}
// MAIN METHOD
public static void main(String[] args) throws IOException{
//instantiate Plaindrom object
Palindrom palObj=new Palindrom();
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String str = "";
do {
System.out.print("Enter some word(Press '/' for end): ");
str = in.readLine();
if (0==str.compareTo("/")){
break;
}else
{
palObj.setter(str);
if (palObj.helper()){
System.out.println("\n"+palObj.getter()+" is Plaindrom!");
}
else{
System.out.println("\n"+palObj.getter()+" is not Plaindrom!");
}
}
}while (true);
} catch (IOException e) {
e.printStackTrace();
}
}//main
1. import java.io.*;
2. import java.lang.*;
3. /**
4. *
5. * @author Developer
6. */
7. public class Palindrome
8. {
9.
10. public static void main(String[] args)throws IOException
11. {
12. Console console=System.console();
13. String word=console.readLine("Enter a word of yr choice");
14. int flag=1;
15. int left=0;
16. int right=word.length()-1;
17. while(left<right)
18. {
19. if(word.charAt(left)!=word.charAt(right))
20. {
21. flag=0;
22. }
23. left++;
24. right--;
25. if(flag==1)
26. {
27. System.out.println("The word" + word + "is a palindrome");
28. }
29. else
30. {
31. System.out.println("The word"+ word + "is not a palindrome");
32. }
33.
34. }
35.
36. }
37. }
{
flag=0;
}
left++;