Android String字符串去除指定首/尾字

Posted 彬sir哥

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android String字符串去除指定首/尾字相关的知识,希望对你有一定的参考价值。

substring():截取字符串

1.String字符串去除指定首字:

String s = "成都市";
s = s.substring(0,s.length()-1);
System.out.print("s =" + s);

结果:

s=成都

2.String字符串去除指定尾字:

String s = "成都市";
s = s.substring(1,s.length());
System.out.print("s =" + s);

结果:

s=都市

以上是关于Android String字符串去除指定首/尾字的主要内容,如果未能解决你的问题,请参考以下文章