File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trim( ) method

 
ankur rathi
Ranch Hand
Posts: 3830
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.out.println("aa aa".trim());

why the output of this statement is :
aa aa

please help ...
thanks .
 
Lakshmi Keshav
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
trim() method removes only leading or trailing blank spaces. Not the spaces in between.
 
Dave Lenton
Ranch Hand
Posts: 1241
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.trim() just removes leading and trailing spaces (i.e. spaces at the start and end of the String). "aa aa" doesn't have any leading or trailing spaces, so gets returned as it is.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rathi, you can find the answers to many of your questions in the API Specs.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
[ January 21, 2005: Message edited by: marc weber ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic