字符串的获取相关方法和字符串的截取相关


字符串的获取相关方法:

String当中与获取相关的常用方法有:

public int length():获取字符串当中含有的字符个数,拿到字符串长度。

public String concat(String str):将当前字符串和参数字符串拼接成为返回值新的字符串。

public char charAt(int index):获取指定索引位置的单个字符。(索引从o开始。)

public int indexOf(String str):查找参数字符串在本字符串当中首次出现的索引位置,如果没有返回-z值。

字符串的获取相关方法和字符串的截取相关

 

 

 

字符串的截取相关:

字符串的截取方法:

public String substring(int index):截取从参数位置一直到字符串末尾,返回新字符串。

public String substring(int begin,int end):截取从begin开始,一直到end结束,中间的字符串。

备注:[ begin , end),包含左边,不包含右边。

字符串的获取相关方法和字符串的截取相关

 

 

搜索

复制

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/270839.html

(0)
上一篇 2022年6月30日
下一篇 2022年6月30日

相关推荐

发表回复

登录后才能评论