package basic; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; //Prime number public class Sample { public static void main(String[] args) throws NumberFormatException, IOException { Scanner scan=new Scanner(System.in); String str=scan.nextLine(); System.out.println(str); System.out.println(str.length()); System.out.println(str.charAt(4)); System.out.println(str.contains("nil")); //Write a program to check wheather my String is //Palendrome } } =========================================================================== package basic; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; //Prime number public class Sample { public static void main(String[] args) throws NumberFormatException, IOException { Scanner scan=new Scanner(System.in); String str=scan.nextLine(); String ans=""; for(int i=str.length()-1;i>=0;i--) { ans=ans+str.charAt(i)+""; } if(ans.equalsIgnoreCase(str)) { System.out.println("Yes palendrome"); }else { System.out.println("Not palendrome"); } //difference between == , equals } } =============================================================== package basic; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; //Prime number public class Sample { public static void main(String[] args) throws NumberFormatException, IOException { Scanner scan=new Scanner(System.in); String str=scan.nextLine(); String ans=""; int i=0; int j=str.length()-1; boolean found=false; for( i=0;i 0) { String s = sc.nextLine(); // Read the input string // Remove surrounding quotes from the string String str = s.substring(1, s.length() - 1); Solution obj = new Solution(); // Create an object of the Solution class String ans = obj.reverseWords(str); // Reverse the words in the string // Print the result with surrounding quotes System.out.println("\"" + ans + "\""); } sc.close(); } } // } Driver Code Ends class Solution { // Function to reverse words in a given string public String reverseWords(String s) { // Code here s=s.trim(); // String arr[]=s.split("/s"); String req=""; String d=""; ArrayList al=new ArrayList<>(); for(int i=0;i=0;i--){ req=req+al.get(i)+" "; } return req.trim(); } } ===========================================================================