Tuesday 24 June 2014

trim()

public String trim()
Returns the string by removing leading and trailing white spaces.

class StringTrim{
 public static void main(String args[]){
  String s1 = new String("   defgh   ");
  String s2 = s1.trim();
  
  System.out.println("s1 = " + s1);
  System.out.println("s2 = " + s2);
 }
}

Output
s1 =    defgh
s2 = defgh




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment