wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes trim( ) method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "trim( ) method" Watch "trim( ) method" New topic
Author

trim( ) method

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
System.out.println("aa aa".trim());

why the output of this statement is :
aa aa

please help ...
thanks .
Lakshmi Keshav
Greenhorn

Joined: Jan 17, 2005
Posts: 7
trim() method removes only leading or trailing blank spaces. Not the spaces in between.
Dave Lenton
Ranch Hand

Joined: Jan 20, 2005
Posts: 1241
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.


There will be glitches in my transition from being a saloon bar sage to a world statesman. - Tony Banks
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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 ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: trim( ) method