Solved

how to remove leading space in a string

Posted on 2008-10-10
3
1,777 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 51
Delete Android all or certain applications data programmatically 9 107
Bot application - advice 3 58
What browser will run Java? 7 122
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

740 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