Posts

Showing posts from June, 2026

Write program to palindrome string

//Method 1  public void PalindromeString{ //main method public static void main(String args[]) { //String declare and initiation   String s="MADAM"; String rev=""; for(int i=s,lenght()-1;i>=0;i--){   rev=rev+s.charAt(i); }       if(s.equals(rev)){        System.out.println("this is palindrome string");//MADAM        }       else{         System.out.println("This is not palindrome screen"); //!=MADAM        }   } } ===================================================== 🔹 Step 1: Start with the Concept A palindrome string is a string that reads the same forward and backward (e.g., "MADAM", "LEVEL"). The logic is to reverse the string and compare it with the original. 🔹 Step 2: Walk Through the Code String Declaration : java String s = "MADAM"; → This is the input string we want to check. Reverse Logic : java String rev = ""; for(int i = s.length() - ...