黑马程序员<java基础<常用类特点>>

------<a href="http://www.itheima.com" target="blank">Java培训、Android培训、iOS培训、.Net培训</a>、期待与您交流! -------

一.正则表达式:
1.字符类;[aeiou]
2.逻辑运算符:&&,| 例子:[a-z&&[^aeiou]]
3.预定义字符类:\\d,.,\\w....
4.限定符:
+:1次或多次;
?: 0次或1次;
*: 0次或多次;
{n} : 必须n次;
{n,}: 至少n次;
{n,m} : 至少n次,最多m次(包含)
5.分组:
二.Math类:
public static int abs(int a):
public static double ceil(double a)
public static double floor(double a)
public static int max(int a,int b) min自学
public static double pow(double a,double b)
public static double random()
public static int round(float a) 参数为double的自学
public static double sqrt(double a)


三.Random类:
1.有"种子"的概念:
2.构造方法:
Random():
Random(int n):使用n做种子;
3.使用相同的种子构造出的Random对象,会产生出相同的随机数序列;
4.成员方法:
nextInt():在int范围内的随机数
nextInt(int m):在0 到 m-1范围内的随机数
5.Random类生成的随机数具有比Math类的random()方法生成的随机性更强。
四.System类:
1.gc():运行垃圾回收器;
2.exit(int status):结束虚拟机;
3.currentTimeMillis():获取当前系统时间的毫秒值;
4.arraycopy():复制数组;
五.BigInteger类:
1. 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类:
1.构造方法:
Date():
Date(long n):使用毫秒构造一个Date
2.成员方法:
getTime():获取毫秒值;
setTime(long n):设置毫秒值
八.SimpleDateFormat类:对日期进行格式化的类;
1.String转换为Date:
String str = "2015-5-30";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date date = sdf.parse(str);
2.Date转换为String:
Date d = new Date();
impleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String str = sdf.format(d);


九.Calendar类
     |--GregorianCalendar类:
    1.构造方法:
GregorianCalendar() 
GregorianCalendar(int year, int month, int dayOfMonth) 
    2.Calendar类的getInstance(),获取一个GregorianCalendar对象。
     |--成员方法:
 get(int field);
 set(int field,int value);
 set(int year,int month,int day);
 add(int field,int value);如果减法,value为负数就可以


十.StringBuffer:
1).StringBuffer是一个容器,可以装一些字符串。
2).它有容量和长度的概念;
3).StringBuffer和String的区别:
1).String不可变的;
2).StringBuffer是容器,内部是可以改变的;
4).如果需要对一个字符串经常的修改,要考虑使用StringBuffer
5).StringBuffer和StringBuilder的区别:
1).StringBuffer是线程安全的。效率低;
2).StringBuilder是线程不安全的。效率高;




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值