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

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

String类型:
        构造方法:
                String(byte[] bytes, int off, int len) :将字节数组从off索引开始的len个字节转换成字符串。
                String(StringBuffer buffer):将StringBuffer类型的对象转换成String类型。
        常用方法:
                char charAt(int index) :返回指定索引处的字符。
                boolean contains(CharSequence s) :判断字符串中是否包含指定的子字符串s,包含返回true,不包含返回false。
                boolean endsWith(String suffix) :测试此字符串是否以指定的后缀结束。是返回true,不是返回false。
                boolean equalsIgnoreCase(String anotherString) :将此 String 与另一个 String 比较,不考虑大小写。
                byte[] getBytes() :将字符串转换成字节数组。
                int indexOf(int ch) :返回指定字符在此字符串中第一次出现处的索引。
                int indexOf(String str) :返回指定子字符串在此字符串中第一次出现处的索引。
                int lastIndexOf(int ch) :返回指定字符在此字符串中最后一次出现处的索引。
                int lastIndexOf(String str) :返回指定子字符串在此字符串中最右边出现处的索引。
                char[] toCharArray() :将此字符串转换为一个新的字符数组。
                String substring(int beginIndex):切割字符串,从指定索引一直切割到最后,得到一个子字符串。
                String substring(int beginIndex, int endIndex):从 beginIndex索引开始切割,一直切割到endIndex,含头不含尾。
                String toUpperCase() :字符串转大写
                String toLowerCase() :字符串转小写
                replace(CharSequence target, CharSequence replacement) :将指定字符串中的target子串替换成replacement。
                String[] split(String regex) :根据给定正则表达式的匹配拆分此字符串。
                static String valueOf(int i):将int类型的整数转换成String类型。 (静态方法,直接用类名调用即可)
               
Integer类型:
        构造方法:
                Integer(String s) :将指定的字符串转换成Integer类型。(注意:s必须是纯数字类型的字符串,有空格或特殊字符均不可以)
        常用方法:
                static int parseInt(String s) :将指定字符串解析成int类型的整数(静态方法直接用类名调用即可,注意:s必须是纯数字类型的字符串,有空格或特殊字符均不可以)

Double类型:
        构造方法:
                Double(String s)  :将指定的字符串转换成Double类型。(注意:s必须是纯数字类型的字符串,有空格或特殊字符均不可以)
        常用方法:
                static double parseDouble(String s)  :将指定字符串解析成double类型的整数(静态方法直接用类名调用即可,注意:s必须是纯数字类型的字符串,有空格或特殊字符均不可以)

StringBuffer类型:
        构造方法:
                StringBuffer(String str) :将String类型转换成StringBuffer类型。
        常用方法:
                StringBuffer append(String str) :将指定的字符串追加到此字符序列。
                       
StringBuilder类型:
        构造方法:
                StringBuilder(String str) :将String类型转换成StringBuffer类型。
        常用方法:
                StringBuilder append(String str) :将指定的字符串追加到此字符序列。
                       
StringBuffer和StringBuilder的区别:
        StringBuffer:StringBuffer线程安全效率低
        StringBuilder:StringBuilder线程不安全效率低
        用法都一样。

Collections工具类(里面的方法全部为静态方法):
        static <T> boolean addAll(Collection<? super T> c, T... elements) :将所有指定元素添加到指定 collection 中。
        static void reverse(List<?> list) :反转指定列表中元素的顺序。
        static void sort(List<T> list):根据元素的自然顺序 对指定列表按升序进行排序。

Arrays工具类:
        static String toString(int[] a) :返回指定数组内容的字符串表示形式。
        static void sort(int[] a) :对指定的 int 型数组按数字升序进行排序。(其他基本类型数组也可使用此方法排序 )
       
Math工具类:
        static int abs(int a):绝对值:
        static double ceil(double a):向上取整
        static double floor(double a):向下取整
        static int max(int a,int b):最大值 (min自学)
        static double pow(double a,double b):a的b次幂
        static double random():随机数 [0.0,1.0)
        static int round(float a) 四舍五入(参数为double的自学)
        static double sqrt(double a):正平方根
       
Random类型:
        public int nextInt():返回的是int范围内的随机数
        public int nextInt(int n):返回的是[0,n)范围的内随机数
       
SimpleDateFormat:
        构造方法:
                SimpleDateFormat() :用默认的模式和默认语言环境的日期格式符号构造 SimpleDateFormat。
                SimpleDateFormat(String pattern) :用给定的模式和默认语言环境的日期格式符号构造 SimpleDateFormat。
        常用方法:
                String format(Date date) :将一个 Date 类型的对象格式化为日期/时间字符串。
                Date parse(String source) :将字符串按照指定的格式解析成日期对象。

3 个回复

倒序浏览
厉害,,,,,,,秒藏
回复 使用道具 举报
不错,已收藏。
回复 使用道具 举报
试着try 发表于 2016-12-9 23:17
不错,已收藏。

好的,欢迎常来
来自宇宙超级黑马专属苹果客户端来自宇宙超级黑马专属苹果客户端
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马