tampurus

3 String classes methods

Mar 24th, 2022 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. public class Main
  2. {
  3.    
  4.     public static void main(String[] args) {
  5.        
  6.        
  7.         String s1 = new String("ramesh ");
  8.         String s2 = "bad boy";
  9.         String res = s1.concat(s2);
  10.         System.out.println(res);
  11.         System.out.println(res.length());
  12.        
  13.         StringBuffer s4 = new StringBuffer("Bad boy");
  14.        
  15.         System.out.println(s4);
  16.         s4.reverse();
  17.         System.out.println(s4);
  18.        
  19.        
  20.         if (s1.equals(s2)){
  21.             System.out.println("S1 and s2 are same");
  22.         }
  23.         else{
  24.             System.out.println("S1 and S2 are not same");
  25.         }
  26.     }
  27. }
  28.  
Add Comment
Please, Sign In to add comment