Solved

how to remove leading space in a string

Posted on 2008-10-10
3
1,776 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 250 total points
ID: 22685125
you can use trim method
like
temp.trim();

0
 
LVL 5

Assisted Solution

by:varungd
varungd earned 250 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 65
SHA2 certs for IIS AND Java? 2 113
ejb entity bean example issue 2 16
restrict decimal places for double datatype 10 19
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 was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.

839 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