ispalindrome function java

Solutions on MaxInterview for ispalindrome function java by the best coders in the world

showing results for - "ispalindrome function java"
Georgina
14 Nov 2017
1import java.util.Scanner;
2
3public class iSPALINDROME {
4
5        public static void main(String[] argh){
6            System.out.print("Enter some integer: ");
7            Scanner input = new Scanner(System.in);
8            String n = input.next();
9            Ispalindrome(n);
10            input.close();
11
12        }
13        public static boolean Ispalindrome(String s) {
14            int length = s.length();
15            int i = 0;
16            int midle = (s.length() / 2);
17            boolean ispalindrome = true;
18            int k = length-1;
19            for (int j = 0; j <= midle& k>=midle; ++j,--k) {
20                if(j==0 & s.charAt(j)=='-'){
21                    ++j;
22                }
23                if (s.charAt(j) == s.charAt(k)){
24                    ispalindrome = true;
25
26                }else{ispalindrome = false;break;}
27            }return print(ispalindrome);
28        }
29
30        public static boolean print(boolean ispalindrome){
31            System.out.println(ispalindrome);
32            return true;
33        }
34
35
36
37}