//************************************** // Name: String Handling // Description:Code for Beginners in Java // By: hari // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //************************************** import java.util.Scanner; class StrB { public static void main(String args[]) { int i, j=0,found=0,len=0; Scanner sc = new Scanner(System.in); System.out.print("Enter your name: "); String string = sc.nextLine(); StringBuilder S=new StringBuilder(string); StringBuilder rev=new StringBuilder(""); int l=S.length(); System.out.println("Program For Implementing String Builder"); System.out.println("***************************************"); System.out.println("The length Of the String =" +l); System.out.println("***************************************"); System.out.println("The Orginal String is =" +S); System.out.println("***************************************"); Scanner sc1 = new Scanner(System.in); System.out.print("Enter The string to concat: "); String string_concat = sc1.nextLine(); StringBuilder S1=new StringBuilder(string_concat); StringBuilder concated=new StringBuilder(""); concated.append(S).append(" ").append(S1); System.out.println("The Concated String is =" +concated); System.out.println("***************************************"); Scanner sc2 = new Scanner(System.in); System.out.print("Enter The string to search: "); String c_srch = sc.nextLine(); StringBuilder S3=new StringBuilder(c_srch ); if(concated.toString().contains(S3.toString())) { System.out.println("This string contains the character:" +S3); System.out.println("***************************************"); } else { System.out.println("This string Doesn't contains the character" +S3); System.out.println("***************************************"); } int l1=concated.length(); for( i=l1-1;i>=0;i--) { rev=rev.append(concated.charAt(i)); } System.out.println("The reversed String is :" +rev); System.out.println("***************************************"); } }