Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Task5 {
- static char[] inputAsArray;
- public static void main(String[] args) {
- if (args.length == 0) {
- System.out.println("Nothing was inputted");
- return;
- }
- String input = args[0];
- inputAsArray = input.toCharArray();
- if(check())
- System.out.println("The word is palindrome");
- else System.out.println("The word is not palindrome");
- }
- static boolean check() {
- int textLength = inputAsArray.length;
- int compareUpTo = textLength/2;
- for (int i=0; i<compareUpTo; i++) {
- if (!(inputAsArray[i]==inputAsArray[textLength-i-1])) return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement