Class java.lang.String


  • Concatenation of strings:
    String str = "d = "+String.valueOf(d)+"cm.";	
    
  • Getting single chars out of the string:
    char c= str.charAt(0);	
    
  • Methods never change the object itself but return a new instance of String. Example for removing leading and following whitespaces:
    String text = "  Hallo  ";
    String result = text.trim();
    System.out.println("Text:"+text+".");
    System.out.println("Result:"+result+".");
      
    Output:
    Text:  Hallo  .
    Result:Hallo.
        

  • Java Tutorial - Standard Classes Jens Trapp, 1997