Object:tostring :输出地址值 如果输出的不是地址值,重写toString
equal:比较地址值 如果不是比较地址值 重写equals方法 比较内容
String:表示字符串
特点:凡是带""String的对象 字符创建之后就无法改变
可以共享
构造:String() String(String s) String(char[] char) String(byte[] bytes) String(char[] char,int offset,int count)->将byte数组的一部分转成String对象
简化:String s = "";
方法:比较功能equal(String s)->比较内容
equalslgnoreCase(String s)->比较内容,忽略大小写
获取功能:charAt(int index)->根据索引 获取对应的字符
subString(int beginnlndex)->截取字符串,从beginlndex开始截取到最后
subString(int beginInext,int endIndex)->截取字符串,含头不含尾
concat(String s)->拼接字符串
IndexOf(String s)->获取指定字符串在原串儿中第一次出现的索引位置
length(0->获取字符串长度
转换功能:getBytes()->将字符串转换成byte数组
toCharArray()->将字符串转成char数组
replace(String s,String s1) ->将s替换成s1
分割:split(String regex)->按照指定的规则分割字符串
扩展功能:trim()->去掉两端空格
startWith(String s)->判断字符串是否以s开头
endsWith(String s)->判断字符串是否以s结尾
toLowerCase()->将字符串换成小写
contain(String s)->判断字符串是否包括s
StringBuider:1概述 :主要用于字符串拼接
2.特点:底层自带缓冲区(char数组),默认长度为16
超出16自动扩容,二倍+2
如何扩容:Array.copyOf->利用的是数组赋值
3.构造StringBuilder()
StringBuilder(String s)
4方法append(任意类型)->字符串拼接,返回的是StringBuilder自己
toString()->将Stringbuilder转成String
reverse()->字符串翻转
Math:1.概述:数学工具类
特点:构造私有
成员为static的
方法:public static int abd(int a)->求参数的绝对值
public static double cell(double a)->向上取整
public static double floor(double a)->向下取整
public static int round (float a)按照四舍五入返回最接近参数的int
static int max (int a, int b)->求两个参数中较大的值
static int min (int a , int b)->求两个参数中较小的值
BigInteger 1.概述:处理大整数
2.构造:BigInteger(String val)->根据传入的符合数字形式的字符串,创建BigInteger对象
3.方法:add(BigInteger value)加
subtract(BIgInteger value)减
multiply(BigInteger value)乘
divide(BigInteger value)除
BigDecimal1.概述:处理小数做运算
构造:BigDecimal(String s)->s必须是数字形式
方法:于上方BigInteger形式相仿
除法做特殊解释PS:当小数除不尽时,程序会报错
采取以下格式解决问题
BigDecimal divide(BigDecimal divesor,int scale,int roundingMode)
divesor:此BigDecimal要除以的值
scale:要保留的位数
roundingMode:舍入方式:1.BigDecima.ROUND_UP 向上加1
2.BigDecimal.ROUND_DOWN 直接舍去
3.BigDecimal.ROUND_HALF_UP 四舍五入
DATE:
概述:表示日期,精确到毫秒___1000毫秒=1秒
2构造:Date()->获取的时当前系统时间
Date(long time)->相当于设置时间,从时间原点开始算
方法:long getTime()->获取当前系统时间的毫秒值
void setTIme(long time)->为时间赋值,传递毫秒值,从时间原点开始往后推算
Calendar:日历类
1.获取:static Calender getInstance()
2方法:public int get(int field):返回给定日历字段的值
public void set(int field,int value):将给定的日历字段设置为给定值.
public abstract void add(int field,int amount ):根据日历的规则,为给定的日历字段添加或减去指定的时间量
public Date getTime():将 Calenbar转成Date对象
4时间字段
SImpleDateFormat:日期格式化类
构造:SimpleDateFormat(String pattern)
字母不能变,连接符可以改变
3.方法1.String format(Date date)将Date对象表示的时间按照指定的格式化,返回的String
2.Date parse(String source)->将符合规则的字符串时间表示形式转成Date对象
LocalDate:jdk8出现的新日期类 主要操作年月日
2获取1.static LocalDate now 90
2.static LocalDate of(int year,Month month,int dayOf(Month)
3.方法获取字段(get开头)int getYear()获取年份
int getMonthValue()返回月份
int getDayOfMonth()返回月中的天数
设置字段(with开头)LocalDate withYear(int year)设置年份
LocalDate withMonth(int month)设置月份
LocalDate withDayOfMonth(int day)设置月中的天数
日期偏移___设置日期字段的偏移量,方法名plus开头,向后偏移
____设置日期字段的偏移量,方法名minus开头,向前偏移
Period概述:计算日期偏差
2方法:sattic Period between(LocalDate d1,LocalDate d2)计算两个日期之间的差值
getYears()->获取相差的年
getMonths()->获取相差的月
getDays()->获取相差的天
Duration1概述:计算日期偏差
方法:static Duration between(Temporal d1,Temporal d2)计算两个日期之间的差值
toMinutes()->获取相差分钟
toDays()->获取相差天数
toMillis()->获取相差小时
DateTimeFormatter1概述:jdk8出现的新日期格式化类
1.获取:static DateTimeFormattert ofPattern(String str)自定义的格式
2.方法:TemporalAccessor parses(String str)自定义的格式
static LocalDateTimefrom(TemporalAccessor temporal)
String format(TemporalAccessor)将日期按照格式转成String