Imran_Mohammed

String_Buffer

Apr 18th, 2022
815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.  
  2. public class NewClass1 {
  3.    
  4.     public static void main(String[] args){
  5.        
  6.         //Declaring String Buffer :
  7.         StringBuffer sb = new StringBuffer("Imran");
  8.         System.out.println(sb);
  9.        
  10.        
  11.         //Appending :
  12.         sb.append(" Mohammed ");
  13.         sb.append(25);
  14.         System.out.println(sb);
  15.        
  16.        
  17.         //String Reverse :
  18.         sb.reverse();
  19.         System.out.println(sb);
  20.        
  21.        
  22.         //String print baseon Index :
  23.         sb.setLength(5);
  24.         System.out.println(sb);
  25.        
  26.        
  27.         //Delete From one Index to Other index
  28.         sb.delete(0, 7);
  29.         System.out.println(sb);
  30.        
  31.     }          
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment