Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public class Task5 {
  2. static char[] inputAsArray;
  3. public static void main(String[] args) {
  4. if (args.length == 0) {
  5. System.out.println("Nothing was inputted");
  6. return;
  7. }
  8. String input = args[0];
  9. inputAsArray = input.toCharArray();
  10. if(check())
  11. System.out.println("The word is palindrome");
  12. else System.out.println("The word is not palindrome");
  13. }
  14.  
  15. static boolean check() {
  16. int textLength = inputAsArray.length;
  17. int compareUpTo = textLength/2;
  18. for (int i=0; i<compareUpTo; i++) {
  19. if (!(inputAsArray[i]==inputAsArray[textLength-i-1])) return false;
  20. }
  21. return true;
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement