Solved

how to remove leading space in a string

Posted on 2008-10-10
3
1,771 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now