java中String相关的方法

public String(byte[] bytes):把字节数组转换成一个字符串

public String(byte[] bytes,int index,int length):把字节数组从index下标开始到length个元素转换成字符串

public String(char[] value):把一个字符数组转换成一个字符串

public String(char[] value,int index,int count):把一个字符数组从index下标处开始的count个字符转换成字符串

public String(String original):把一个字符串转换成一个字符串

public boolean equals(Object obj):比较字符串是否相等,比较的是内容,区分大小写

public boolean equalsIgnoreCase(String str):比较字符串是否相等,比较的是内容,不去分大小写

public boolean contains(String str):判断一个字符串是否包含str字符串

public boolean startsWith(String str):判断一个字符串是否以str这个字符串开始

public boolean endsWith(String str):判断一个字符串是否以str这个字符串结尾

public boolean isEmpty():判断一个字符串是不是空串

public int length():获取一个字符串的长度

public char charAt(int index):查找一个字符串中对应索引的字符

public int indexOf(int ch):返回指定字符在次字符串中第一次出现的索引

public int indexOf(String str):查找一个字符串第一个字符出现时的索引

public int indexOf(int ch,int fromIndex):返回指定字符在此字符串中从指定位置后第一次出现的索引

public int indexOf(String str,int fromIndex):查找一个字符串中字符第fromIndex次出现的索引

public String substring(int start):从指定位置开始截取字符串,默认到末尾

public String substring(int start,int end):从指定位置开始开始带指定位置结束截取字符串

public byte[] getBytes():把字符串转换为字节数组

public char[] toCharArray():把字符串转换为字符数组

public static String valueOf(char[] ch):把字符数组转换为字符串

public static String valueOf(int i):把int类型的数据转换为字符串

public String toLowerCase():把字符串转换为小写

public String toUpperCase():把字符串转为大写

public String concat(String str):把字符串拼接

public String replace(char old,char new):将指定字符进行互换

public String replace(String old,String new):将指定字符串进行互换

public String trim():去除字符串两端的空格

public int compareTo(String str):对照ASCII码表,从第一个字母进行减法运算,返回该减法的结果

public int compareToIgnoreCase(String str):不区分大小写返回减法的结果

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值