当前位置: 代码迷 >> 综合 >> java字符串常用方法
  详细解决方案

java字符串常用方法

热度:28   发布时间:2024-02-05 19:16:00.0

boolean equals(String str);

boolean equalsIgnoreCase(String str);

int length();

String concat(String str);//拼接字符串

char charAt(int index);//获取索引位置字符

int indexOf(String str);//查找参数字符串在本字符串中首次出现的索引位置,如果没有返回-1

String substring(int begin);//截取字符串,从参数位置到字符串结尾

String substring(int begin,int end);//截取字符串,左闭右开

char[] toCharArray();//将当前字符串拆分为字符数组作为返回值

byte[] getBytes();//获得当前字符串底层的字节数组

String replace(charSequence oldString,charSequence newString);//将所有出现的老字符串替换为新字符串,返回替换后的

String[] split(String regex);//按照参数规则,将字符串切分为若干部分