构造方法:(掌握,重点是能知道什么意思)
public String() 空参数构造方法
public String(byte[] bytes) 把字节数组转换字符串
public String(byte[] bytes, int startIndex, int length) 把字节数组一部分元素 转换成字符串
public String(char[] value) 把字符数组 转换成字符串
public String(char[] value, int startIndex, int count) 把字符数组一部分元素 转换成字符串
public String(String original) 就是字符串字面值,封装成对象
StringBuffer/StringBuilder:(掌握)
构造方法:
public StringBuffer() 创建一个字符串缓冲区,默认容量大小16
public StringBuffer(int capacity) 创建一个字符串缓冲区,指定容量大小
public StringBuffer(String str) 创建一个字符串缓冲区,指定默认内容为 str 的内容,长度为 字符串str的长度 + 16
方法:
public StringBuffer append(String str) 在原有字符串缓冲区内容基础上,在末尾追加新数据
public StringBuffer insert(int offset,String str) 在原有字符串缓冲区内容基础上,在指定位置插入新数据
public StringBuffer deleteCharAt(int index) 在原有字符串缓冲区内容基础上,删除指定位置上的字符
public StringBuffer delete(int start,int end) 在原有字符串缓冲区内容基础上,删除指定范围内的多个字符
public StringBuffer replace(int start,int end,String str)在原有字符串缓冲区内容基础上,将指定范围内的多个字符 用给定的字符串替换
public StringBuffer reverse() 将字符串缓冲区的内容 反转
public String substring(int start) 从指定位置开始,到末尾结束,截取该字符串缓冲区,返回新字符串
public String substring(int start,int end) 从指定位置开始,到指定位置结束,截取该字符串缓冲区,返回新字符串
Arrays:
方法:
public static int binarySearch(int[] a, int key) 二分查找
public static void sort(int[] a) 数组排序[冒泡排序,选择排序]
public static String toString(int[] a) 把各种类型的数组,转换成字符串形式
Integer:
构造方法:
public Integer(int value) 把基本数据类型int值 , 封装成对象
public Integer(String s) 把字符串类型的数字字符,封装成对象
方法:
public static String toBinaryString(int i) 10进制 --> 2进制
public static String toOctalString(int i) 10进制 --> 8进制
public static String toHexString(int i) 10进制 --> 16进制
public static String toString(int i,int radix) 10进制 --> x进制
public static int parseInt(String s,int radix) x进制 --> 10进制
public String toString() 把Integer中的数值 转换成 字符串 Integer --> String
public static String toString(int i) 把基本数据类型 int值 转成 字符串 int --> String
public int intValue() 把Integer中的数值 获取出来, 返回一个基本数据类型 int 值 Integer --> int
public static int parseInt(String s) String --> int
public static Integer valueOf(String s) String -->Integer 作者: lgdbest 时间: 2016-3-21 22:06
正则表达式的语法规则:(了解)
数量词:格式 例如:
X? X,一次或一次也没有 "a?" ---> 需要匹配的内容是一个字符a,或者一个a都没有
X* X,零次或多次 "a*" ---> 需要匹配的内容是多个字符a,或者一个a都没有
X+ X,一次或多次 "a+" ---> 需要匹配的内容是多个字符a,或者一个a
X{n} X,恰好 n 次 "a{5}"--> 需要匹配的内容是5个字符a
X{n,} X,至少 n 次 "a{5, }"--> 需要匹配的内容是最少有5个字符a
X{n,m} X,至少 n 次,但是不超过 m 次 "a{5,8}"--> 需要匹配的内容是有5个字符a 到 8个字符a之间
--------------------------
判断功能
public boolean matches(String regex) 该字符串是否与正则表达式规则相匹配
分割功能
public String[] split(String regex) 将字符串使用正则表达式进行分割,返回一个分割后的字符串数组
替换功能:
public String replaceAll(String regex, String replacement) 将满足正则表达式规则的字符串内容,用给定的新字符串进行替换,
获取功能:
Pattern: 正则表达式对象
方法:
public static Pattern compile(String regex) 将正则表达式字符串 编译成正则表达式对象
public Matcher matcher(CharSequence input) 使用正则表达式对象与给定的数据进行匹配,将结果封装成对象,匹配器对象
Matcher: 匹配器对象
public boolean find() 在指定的字符串中,查找是否有满足正则表达式条件的子字符串信息
public String group() 获取满足正则表达式条件的子字符串
public boolean matches()获取指定的字符串与正则表达式规则匹配的结果
-------------------------
Character: char包装类()
public static boolean isUpperCase(char ch) 判断给定字符是否为大写字母
public static boolean isLowerCase(char ch) 判断给定字符是否为小写字母
public static boolean isDigit(char ch) 判断给定字符是否为数字
public static char toUpperCase(char ch) 把给定的字符转换成大写
public static char toLowerCase(char ch) 把给定的字符 转换成小写
Math: 数学工具类
public static double abs(double a)返回 double 值的绝对值
public static double cbrt(double a)返回 double 值的立方根
public static double ceil(double a)返回比参数值大的最小整数
public static double floor(double a)返回比参数值小的最大整数
public static double max(double a, double b)返回两个 double 值中较大的一个
public static double min(double a, double b)返回两个 double 值中较小的一个
public static double pow(double a, double b)返回a的b次方
public static double random() 返回 0.0<=x<1.0 之间的随机小数
public static long round(double a) 四舍五入
public static double sqrt(double a)返回正确舍入的 double 值的正平方根
Random: 随机数类
构造方法:
public Random():
使用默认的种子来创建随机数对象, 默认的种子就是当前系统时间的毫秒值
public Random(long seed):
使用指定的种子来创建随机数对象
方法:
public int nextInt(): 返回一个随机的int范围内的整数
public int nextInt(int n)返回一个,在 0(包括)和指定值(不包括)之间int随机数
System:
成员变量:
public static final InputStream in
标准输入流, 对应的就是 键盘输入
public static final PrintStream out
标准输出流,对应的就是 显示器输出
方法:
public static void exit(int status)
终止当前正在运行的 Java 虚拟机。参数用作状态码;根据惯例,非 0 的状态码表示异常终止
public static long currentTimeMillis()
返回当前系统时间的毫秒值
public static void gc()
运行垃圾回收器,调用 gc 方法暗示着 Java 虚拟机做了一些努力来回收未用对象,以便能够快速地重用这些对象当前占用的内存
BigInteger:超出int范围的整数
public BigInteger add(BigInteger val) 加法
public BigInteger subtract(BigInteger val) 减法
public BigInteger multiply(BigInteger val) 乘法
public BigInteger divide(BigInteger val) 除法,返货商
public BigInteger[] divideAndRemainder(BigInteger val) 除法,返回商和余数
BigDecimal: 精确的小数
public BigDecimal add(BigDecimal augend) //加法
public BigDecimal subtract(BigDecimal subtrahend) 减法
public BigDecimal multiply(BigDecimal multiplicand) 乘法
public BigDecimal divide(BigDecimal divisor) //除法
public BigDecimal divide(BigDecimal divisor,int scale,int roundingMode)//除法,带有保留指定小数点位数的四舍五入的方法
Date: 日期/时间类
构造方法
public Date()// 系统当前日期时间
public Date(long date) 得到一个1970年1月1日 0点这个时间基础上,加上参数date 毫秒值对应的日期时间
成员方法
public long getTime() 获取日期/时间对应的毫秒值
public void setTime(long time) 通过毫秒值设置日期/时间
DateFormat:是日期/时间格式化子类的抽象类, 使用其子类SimpleDateFormat 实例化
SimpleDateFormat
构造方法
public SimpleDateFormat() 默认的格式化操作
public SimpleDateFormat(String pattern) 按照指定的格式,进行日期格式化
日期和时间模式
y 年
M 年中的月份
d 月份中的天数
H 一天中的小时数(0-23)
m 小时中的分钟数
s 分钟中的秒数
S 毫秒数
成员方法
public final String format(Date date) 把日期 格式化成字符串
public Date parse(String source) 把日期字符串 转换成 日期对象
Calendar: 日历类
public static Calendar getInstance() 获取到一个日历类对象
public int get(int field) 返回指定日期字段所对应的值
public void add(int field,int amount) 更新指定日期字段的值
public final void set(int year,int month,int date)设置指定日期字段的值