Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class isPallindrom {
- private static boolean isPallindrom(String str) {
- if (str == null)
- return false;
- int length = str.length();
- //System.out.println(length/2);
- String str2 = str.toLowerCase();
- for (int i = 0; i < length/2; i++) {
- if (str2.charAt(i) != str2.charAt(length - i -1))
- return false;
- }
- return true;
- }
- public static void main(String[] args) {
- String hello = "Hello olleh";
- System.out.println(isPallindrom(hello));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement