This website includes Education Information like a programming language, job interview question, general knowledge.mathematics

Education log

PageNavi Results No.

Ads

Sunday, August 20, 2023

Java Program to Check Palindrome example

 Java Program to Check Palindrome example


In this Tutorial Java Program to Check Palindrome example follow this example,


class Main {

  public static void main(String[] args) {


    String str = "Radar", reverseStr = "";

    

    int strLength = str.length();


    for (int i = (strLength - 1); i >=0; --i) {

      reverseStr = reverseStr + str.charAt(i);

    }


    if (str.toLowerCase().equals(reverseStr.toLowerCase())) {

      System.out.println(str + " is a Palindrome String.");

    }

    else {

      System.out.println(str + " is not a Palindrome String.");

    }

  }

}

No comments:

Post a Comment