Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ApplicationRunner {
- public static String CHECKING_SENTENCE = "topot";
- public static void main(String[] args) {
- System.out.println(isPalindrome(CHECKING_SENTENCE));
- }
- public static boolean isPalindrome(String sentence) {
- boolean isValid = true;
- int sentenceLength = sentence.length();
- for (int i = 0; i < sentenceLength / 2 && isValid; ++i) {
- isValid = sentence.charAt(i) == sentence.charAt(sentenceLength - i - 1);
- }
- return isValid;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement