Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to remove leading space in a string

Posted on 2008-10-10
3
Medium Priority
?
1,784 Views
Last Modified: 2013-12-29
how to remove leading space in a string

for example

String temp="apple                               ";

i want to remove all the space at the end, and would be

String temp="apple"
0
Comment
Question by:priyapratheep
3 Comments
 
LVL 6

Accepted Solution

by:
divyeshhdoshi earned 750 total points
ID: 22685125
you can use trim method
like
temp.trim();

0
 
LVL 5

Assisted Solution

by:varungd
varungd earned 750 total points
ID: 22685210
String temp = "apple                               ".Trim();

or  

temp=temp.Trim();
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 22685260
There is no method like Trim(); its trim()


String temp = temp.trim();
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question