File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
Don't get me started about those stupid light bulbs.
 
subject: trim( ) method
 
Similar Threads
server side validation
How many strings are created?
string how it works
howto set DIV and make display
focus listener