Extract substring from a string

2019-01-13 19:59发布

what is the best way to extract a substring from a string in android?

9条回答
神经病院院长
2楼-- · 2019-01-13 20:20

Here is a real world example:

String hallostring = "hallo";
String asubstring = hallostring.substring(0, 1); 

In the example asubstring would return: h

查看更多
在下西门庆
3楼-- · 2019-01-13 20:23

You can use subSequence , it's same as substr in C

 Str.subSequence(int Start , int End)
查看更多
forever°为你锁心
4楼-- · 2019-01-13 20:25

substring():

str.substring(startIndex, endIndex); 
查看更多
登录 后发表回答