fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args) throws java.lang.Exception
  9. {
  10. System.out.print("Type one or more words: ");
  11. String s = "Noon";
  12. int count = 0;
  13. for(int i = 0; i < s.length();i++) {
  14. char a = s.charAt(i);
  15. char b = s.charAt(s.length()-(i+1));
  16. if (a==b) {
  17. count ++;
  18. } else {
  19. count = count;
  20. }
  21. }
  22. if (count == s.length()) {
  23. System.out.print(s + " is a palindrome!");
  24. } else {
  25. System.out.print(s + " is not a palindrome.");
  26. }
  27. }
  28. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
Type one or more words: Noon is not a palindrome.