String 截取、分割、定位

截取

public String substring(int beginIndex, int endIndex),返回新的字符串,参数为 前闭后开

public String substring(int beginIndex),返回新的字符串,从参数位置开始截取到末尾

定位

public char charAt(int index),返回指定下标的字符串

分割

public String[] split(String regex[, int limit]),用指定的符号来分组,limit 可选,.$|* 需要加转义符 \

String str = new String("Welcome-to-Runoob");
// Welcome,to-Runoob
str.split("-", 2);
posted @ 2023-02-10 17:03  CyrusHuang  阅读(115)  评论(0编辑  收藏  举报