1.常用类math和sysytem和Random的介绍
public static final double E :
public static final double PI:
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)
public static int min(int a, int b)
public static double pow(double a,double b)
public static double random()
public static int round(float a)
public static double sqrt(double a)
public Random()
public Random(long seed)
public int nextInt()
public int nextInt(int n)
void nextBytes(byte[] bytes)
public static void gc()
public static void exit(int status)
public static long currentTimeMillis()
2.Date日期类的介绍
public Date()
public Date(long date)
public long getTime():
public void setTime(long time):
3.Calendar日历类的介绍
4.数组和集合的区别
public class MyTest2 {
public static void main(String[] args) {
Student student1 = new Student("张三", 23);
Student student2 = new Student("李四", 24);
Student student3 = new Student("王伟", 25);
Collection collection=new ArrayList();
boolean b = collection.add(student1);
collection.add(student2);
collection.add(student3);
System.out.println(collection);
}
}
5.Collection集合的使用
Collection的功能概述(通过API查看即可得到)
a:添加功能
boolean add(Object obj):添加一个元素
boolean addAll(Collection c):添加一个集合的元素 (给一个集合添加进另一个集合中的所有元素)
b:删除功能
void clear():移除所有元素
boolean remove(Object o):移除一个元素
boolean removeAll(Collection c):移除一个集合的元素(移除一个以上返回的就是true) 删除的元素是两个集合的交集元素
如果没有交集元素 则删除失败 返回false
c:判断功能
boolean contains(Object o):判断集合中是否包含指定的元素
boolean containsAll(Collection c):判断集合中是否包含指定的集合元素(这个集合 包含 另一个集合中所有的元素才算包含 才返回true)
比如:1,2,3 containsAll 12=true 1,2,3 containsAll 2,3,4=false
boolean isEmpty():判断集合是否为空
d:获取功能
Iterator<E> iterator()(重点)
e:长度功能
int size():元素的个数
面试题:数组有没有length()方法呢?字符串有没有length()方法呢?集合有没有length()方法呢?
f:交集功能
boolean retainAll(Collection c):获取两个集合的交集元素(交集:两个集合都有的元素)
g:把集合转换为数组
Object[] toArray()