how to remove leading space in a string

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"
priyapratheepAsked:
Who is Participating?
 
divyeshhdoshiCommented:
you can use trim method
like
temp.trim();

0
 
varungdCommented:
String temp = "apple                               ".Trim();

or  

temp=temp.Trim();
0
 
Ajay-SinghCommented:
There is no method like Trim(); its trim()


String temp = temp.trim();
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.