| Author |
Remove last element of string
|
Sanj Sharma
Ranch Hand
Joined: Feb 14, 2004
Posts: 32
|
|
Hi Any one who know how to remove the last element of string. Say i have string "0000." and i just want to remove "." from it and make it "0000"
|
 |
Nischal Tanna
Ranch Hand
Joined: Aug 19, 2003
Posts: 182
|
|
Originally posted by Girish Sharma: Hi Any one who know how to remove the last element of string. Say i have string "0000." and i just want to remove "." from it and make it "0000"
Use substring() method of String class..Referring ur example
|
Thnx
|
 |
Sanj Sharma
Ranch Hand
Joined: Feb 14, 2004
Posts: 32
|
|
|
Thanks, Nischal.
|
 |
Sanj Sharma
Ranch Hand
Joined: Feb 14, 2004
Posts: 32
|
|
|
This will remove all the elements except last i want to remove last element only.
|
 |
newgen pras
Ranch Hand
Joined: Jun 01, 2005
Posts: 34
|
|
This will remove the last element only .... String str = "0000." str = str.substring(0,str.length()-1) System.out.println(str) Regards Prasanna
|
 |
Geoffrey Falk
Ranch Hand
Joined: Aug 17, 2001
Posts: 171
|
posted

0
|
Be sure to test for the case of a zero-length string, otherwise you will get an exception. Geoffrey
|
Sun Certified Programmer for the Java 2 Platform
|
 |
 |
|
|
subject: Remove last element of string
|
|
|