Saturday, February 9, 2019

String Manipulations


 public class Str {  
  public static void main(String[] args) {  
  String s = "Mutturaj Hulagabal";  
  System.out.println(s.charAt(4));  
  System.out.println(s.length());  
  String trim = s.trim();  
  System.out.println(trim.length());  
  System.out.println(s.concat("Atharga"));  
  System.out.println(s.contains("Muttu"));  
  System.out.println(s.indexOf("H"));  
  System.out.println(s.compareTo("Naveen Patil"));  
  System.out.println(s.toUpperCase() + " " + s.toLowerCase());  
  System.out.println(s.compareTo("Mutturaj Hulagabal"));  
  System.out.println(s.compareToIgnoreCase("mutturaj hulagabal"));  
  System.out.println(s.isEmpty());  
  // Sub String  
  System.out.println(s.substring(9));  
  System.out.println(s.substring(0, 8));  
  // Object  
  System.out.println(s.equals("Mutturaj Hulagabal"));  
  }  
 }  


No comments:

Post a Comment