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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© hacker◊紫猫 中级黑马   /  2014-10-2 23:26  /  1854 人查看  /  11 人回复  /   2 人收藏 转载请遵从CC协议 禁止商业使用本文

在学习API是有许多的方法让我们目不暇接,其中有许多重要的方法,我记在了笔记上
这些方法都是必须背过记住的,记住代码的最佳途径是多敲,多连,敲到多了也就记住了
我从几个类先开始写
1,Object:
有两个equals()和toString()这两个方法很常见但是建类的最好重写这两个方法。
2,String:
这个方法比较多重要的也比较多。
构造方法:
                A:String s = new String();
                B:String s = new String(byte[] bys);
                C:String s = new String(byte[] bys,int index,int length);
                D:String s = new String(char[] chs);
                E:String s = new String(char[] chs,int index,int length);
                F:String s = new String(String str);
                G:String s = "hello";
成员方法:
                A:判断功能
                        boolean equals(Object obj)


                        boolean equalsIgnoreCase(String str)
                        boolean contains(String str)
                        boolean startsWith(String str)
                        boolean endsWith(String str)
                        boolean isEmpty()
                B:获取功能
                        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)
                        String substring(int start)
                        String substring(int start,int end)
                C:转换功能
                        byte[] getBytes()
                        char[] toCharArray()
                        static String copyValueOf(char[] chs)
                        static String valueOf(char[] chs)
                        static String valueOf(int i)
                        String toLowerCase()
                        String toUpperCase()
                        String concat(String str)
其他功能
                a:替换功能
                        String replace(char oldChar,char newChar)
                        String replace(String oldString,String newString)


                b:切割功能
                        String[] split(String regex)
                       
                c:去除两端空格功能
                        String trim()
                       
                d:字典顺序比较功能
                        int compareTo(String str)
                        int compareToIgnoreCase(String str)
3,Arrays:
        (1)Arrays是针对数组操作的工具类。
        (2)成员方法:
                public static String toString(数组):把数组变成字符串。
                public static void sort(数组):对数组进行排序。重要可以快速排序。
                public static int binarySearch(int[] arr,int value):二分查找
4,System:
        (1)系统类,提供了静态的变量和方法供我们使用。
        (2)成员方法:
                public static void exit(int value):退出jvm,非0表示异常退出。
                public static long currentTimeMillis():返回当前系统时间的毫秒值。
                        和1970 年 1 月 1 日午夜之间的时间差
5,StringBuffer
        (1)字符个数可以发生改变的字符串类。字符串缓冲区类。
        (2)构造方法:
                A:StringBuffer()
                B:StringBuffer(int capacity)
                C:StringBuffer(String str)
        (3)成员方法:(自己补齐)
                A:添加功能
                         Append()
                B:删除功能
                         Delete(int x,int y)               
                C:替换功能
                        replace()
                D:截取功能
                        subString(int x,int y)
                E:反转功能
                        reverse()
                F:插入功能
                        insert()


大体就这些了,还有几个类我就不一一叙述了。

11 个回复

倒序浏览
不错,顶一个
回复 使用道具 举报
简洁明了,赞!
回复 使用道具 举报
嗯嗯 顶一下
回复 使用道具 举报
总结的很好!复习下
回复 使用道具 举报
顶一下!!!
回复 使用道具 举报
mark :) 收藏
回复 使用道具 举报
路过,慢跑中。。
回复 使用道具 举报
不错不错  顶一个
回复 使用道具 举报
赞一个!!
回复 使用道具 举报
weiyi 中级黑马 2014-10-5 18:10:33
11#
那么多都要记住吗:funk:
回复 使用道具 举报
很简单明了啊
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马