Java15 常用类库

StringBuffer类

StringBuffer sbf = new StringBuffer("Hello ");

sbf.append("World!");

对比String的优势

 

CharSequence接口

 

AutoCloseable接口

try(){

}catch(Exception e){

}

 

Runtime类

Runtime runtime = Runtime.gerRuntime();

runtime.availableProcessors();

Runtime.getRuntime().gc();

 

System类

System.currentTimeMillis();

System.gc();

 

Cleaner类

 

 

克隆对象

实现接口后可以克隆。(克隆接口表示一种能力)

 

Math数学计算

静态方法

 

Random随机数

Ramdom rd = new Ramdom();

rd.nextInt();    //不含后边界的随机整数

 

大数字处理

BigInteger

BigDecimal         

  • /ˈdesɪml/

 

 

Date日期处理类

Date date = new Date();

 

 

SimpleDateFormat日期格式化

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");

String now = sdf.format(new Date());

//SimpleDateFormat

public class SimpleDateFormatDemo{
         public static void main(String args[]){

              SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
              String now = sdf.format(new Date());
              System.out.println(now);
         }
}

程序运行结果

2021-06-08 16:37:11.187

 

 

 

正则表达式

/d /w [a-zA-Z0-9]  [^012]

?*+{n,m}

XY,   X|Y,  ()

 

国际化程序

Locale lc = new Locale("zh","CN");

Locale lc = Locale.getDefault();

Locale lc = Locale.CHINA;

//Locale
import java.util.Locale;

public class LocaleDemo{
       public static void main(String args[]){
                Locale lc = new Locale("zh", "CN");
                System.out.println(lc);           
      }
}

程序运行结果:

zh_CN

 

posted @ 2021-06-08 16:42  legendary_tm  阅读(41)  评论(0编辑  收藏  举报