java数据结构 • 面向对象 • 异常 • 随机数·时间

• 语法基础

• 控制流
• 数据结构
• 面向对象
• 异常
• 随机数
//String常用的方法;
indexOf
 
charAt
 
charAt
 
codePointAt
 
compareToIgnoreCase //忽略大小写;
 
compareTo //比较
 
toUpperCase
 
endsWith
 
cntains
 
replaceAll
 
StringBuilder //线程非安全
StringBuffer //线程安全
append('') //添加
 
 
 
 
控制流:
targart = a == 2? 1:3; //三目运算符号
switch ( ){ //switch结构
case a :
break;
defult:
未知:
}
 
 
//数据结构
HashTable //线程安全
HashMap //线程不安全
addAll() //合并
remove() //对象,对应位置
get() //
 
 
Collections.reverse(); //数组的反转
Collections.sort( ); // 数组的排序;
Collections.sort(str,new Comparator<String> (){
public int compareTo(String str1,String str2)
return str2.compareTo(str1);
})
 
Collections.shuffle(shuzu); //数组的随机打乱
 
 
 
 
 
UUID.randomUUID(); //生成随机字符串
 
 
 
//随机数的生成:
Random random = new Random();
//random.setSeed(1); //产生固定的随机数
random.nexInt();
 
 
 
//时间 类:
Date date = new Date();
date.getTime(); //获取时间
dateFormate df = nwe dateFormate("MM/dd/yyyy HH:mm:ss");
 

原文地址:https://www.cnblogs.com/liguo-wang/p/9388194.html