A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 320215787 中级黑马   /  2016-4-26 22:49  /  570 人查看  /  7 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文


* A:常见构造方法
        * public String():空构造
        * public String(byte[] bytes):把字节数组转成字符串
        * public String(byte[] bytes,int index,int length):把字节数组的一部分转成字符串
        * public String(char[] value):把字符数组转成字符串
        * public String(char[] value,int index,int count):把字符数组的一部分转成字符串
        * public String(String original):把字符串常量值转成字符串

* A:String类的判断功能
        * boolean equals(Object obj):比较字符串的内容是否相同,区分大小写
        * boolean equalsIgnoreCase(String str):比较字符串的内容是否相同,忽略大小写
        * boolean contains(String str):判断大字符串中是否包含小字符串
        * boolean startsWith(String str):判断字符串是否以某个指定的字符串开头
        * boolean endsWith(String str):判断字符串是否以某个指定的字符串结尾
        * boolean isEmpty():判断字符串是否为空。

* A:String类的获取功能
        * int length():获取字符串的长度。
        * char charAt(int index):获取指定索引位置的字符
        * int indexOf(int ch):返回指定字符在此字符串中第一次出现处的索引。
        * int indexOf(String str):返回指定字符串在此字符串中第一次出现处的索引。
        * int indexOf(int ch,int fromIndex):返回指定字符在此字符串中从指定位置后第一次出现处的索引。
        * int indexOf(String str,int fromIndex):返回指定字符串在此字符串中从指定位置后第一次出现处的索引。
        * lastIndexOf
        * String substring(int start):从指定位置开始截取字符串,默认到末尾。
        * String substring(int start,int end):从指定位置开始到指定位置结束截取字符串。

* A:String的转换功能:
        * byte[] getBytes():把字符串转换为字节数组。
        * char[] toCharArray():把字符串转换为字符数组。
        * static String valueOf(char[] chs):把字符数组转成字符串。
        * static String valueOf(int i):把int类型的数据转成字符串。
                * 注意:String类的valueOf方法可以把任意类型的数据转成字符串。


        * String toLowerCase():把字符串转成小写。(了解)
        * String toUpperCase():把字符串转成大写。
        * String concat(String str):把字符串拼接。
       

* A:String的替换功能
        * String replace(char old,char new)
        * String replace(String old,String new)

* B:String的去除字符串两空格
        * String trim()

* C:String的按字典顺序比较两个字符串
        * int compareTo(String str)(暂时不用掌握)
        * int compareToIgnoreCase(String str)(了解)

7 个回复

倒序浏览
自己总结的挺不错  谢谢分享
回复 使用道具 举报
全部都要背下来!
回复 使用道具 举报
学习学习
回复 使用道具 举报
不错不错
回复 使用道具 举报
3Q 已保存
回复 使用道具 举报
很赞!!!
回复 使用道具 举报
晚上还写了一遍,听赞
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马