zoukankan      html  css  js  c++  java
  • String类常用方法

    No.

    方法名称

    类型

    描述

    01

    public String​(char[] value)

    构造

    将一个字符数组的全部内容转为字符串

    02

    public String​(char[] value, int offset, int count)

    方法

    将部分字符数组转为字符串,参数的作用如下:

             · offset:字符数组的操作索引位置;

             · count:要操作的字符数组的内容数量。

    03

    public char charAt​(int index)

    方法

    获取指定索引位置上的字符内容

    04

    public char[] toCharArray()

    方法

    将字符串转为字符数组

    05

    public String​(byte[] bytes)

    构造

    将接收的全部字节数组转为字符串

    06

    public String​(byte[] bytes, int offset, int length)

    方法

    将部分字节数组转为字符串

    07

    public byte[] getBytes()

    方法

    将字符串转为字节数组

    08

    public byte[] getBytes​(String charsetName) throws UnsupportedEncodingException

    方法

    实现编码转换

    09

    public boolean equals​(String anObject)

    方法

    区分大小写比较

    10

    public boolean equalsIgnoreCase​(String anotherString)

    方法

    忽略大小写比较

    11

    public int compareTo​(String anotherString)

    方法

    比较大小关系

    12

    public int compareToIgnoreCase​(String str)

    方法

    忽略大小实现关系比较

    13

    public boolean contains​(String s)

    方法

    查找指定的子字符串是否存在

    14

    public int indexOf​(String str)

    方法

    从首部查找指定子字符串的位置,找不到返回-1

    15

    public int indexOf​(String str, int fromIndex)

    方法

    从指定位置查找子字符串的位置,找不到返回-1

    16

    public int lastIndexOf​(String str)

    方法

    从后向前查找子字符串的位置

    17

    public int lastIndexOf​(String str, int fromIndex)

    方法

    从指定位置由后向前查找子字符串的位置

    18

    public boolean startsWith​(String prefix)

    方法

    是否以指定的字符串开头

    19

    public boolean startsWith​(String prefix, int toffset)

    方法

    是否在指定的索引位置开始以指定的字符串开头

    20

    public boolean endsWith​(String suffix)

    方法

    是否以指定的字符串结尾

    21

    public String substring​(int beginIndex)

    方法

    从指定索引位置截取到结尾

    22

    public String substring​(int beginIndex, int endIndex)

    方法

    截取指定索引范围的子字符串

    23

    public String replaceAll​(String regex, String replacement)

    方法

    字符串全部替换

    24

    public String replaceFirst​(String regex, String replacement)

    方法

    替换首个内容

    25

    public String[] split​(String regex)

    方法

    全部拆分

    26

    public String[] split​(String regex, int limit)

    方法

    部分拆分,其中limit表示的数组拆分后的长度

    27

    public String intern()

    方法

    对象池保存

    28

    public boolean isEmpty()

    方法

    判断是否为空字符串(不是null)

    29

    public int length()

    方法

    获取字符串长度

    30

    public String trim()

    方法

    去掉左右空格

    31

    public String toUpperCase()

    方法

    转大写

    32

    public String toLowerCase()

    方法

    转小写

    33

    public String concat​(String str)

    方法

    字符串连接

    34

    public static String format​(String format, 数据类型... args)

    方法

    字符串格式化方法,使用格式化标记进行处理

  • 相关阅读:
    报表容器元素的典型用途:保持位置关系+表角斜线
    如何在Wyn仪表板中实现文件下载
    报表表格中的迷你图
    怎么实现固定行数的表格类报表
    如何把自己设计好的仪表板分享给别人?
    报表中的【子弹图】实现方法
    来自不同数据集的图表如何设置联动
    仪表板图表条件格式化设置
    报表中的数据格式设置方法汇总
    仪表板数据表根据用户需求可以自由选择查看的数据列
  • 原文地址:https://www.cnblogs.com/luliang888/p/10902485.html
Copyright © 2011-2022 走看看