2011-02-27 47 views
77

刪除字符串的前3個字符的最有效方法是什麼?刪除字符串中的前3個字符

例如:

 
'apple' change to 'le' 
'a cat' change to 'at' 
' a b c'change to 'b c' 
+7

你應該學習[String in Java]的基礎知識(http://download.oracle.com/javase/1.5.0/docs/api/java/lang/String.html)。 – 2011-02-27 06:52:31

+0

可能重複[在Java中,刪除字符串的第一個字符](http://stackoverflow.com/questions/4503656/in-java-removing-first-character-of-a-string) – 2014-02-11 15:14:30

+0

請在搜索之前先搜索的問題。以前肯定有這樣一個基本問題。 – 2014-02-11 15:14:59

回答

203

只需使用字符串:"apple".substring(3);將返回String類的le

+1

是的,它的工作.. – 2014-02-14 13:12:33

7

使用子方法:
string.substring(3);

6

使用String類的substring方法:

String removeCurrency=amount.getText().toString().substring(3);