Java ArrayList和继承
1. Math类(方法补充及复习)
public class Demo01Math {
public static void main(String[] args) {
//求绝对值
int a = Math.abs(-9);
System.out.println("求绝对值:(abs -9)"+a);
//向上取整
double ceil = Math.ceil(3.14);
System.out.println("向上取整:(ceil 3.14)"+ceil);
double ceil1 = Math.ceil(-3.14);
System.out.println("向上取整:(ceil -3.14)"+ceil1);
//向下取整
double floor = Math.floor(3.99);
System.out.println("向下取整:(floor 3.99)"+floor);
double floor1 = Math.floor(-3.99);
System.out.println("向下取整:(floor -3.99)"+floor1);
//四舍五入 参数+0.5 再进行floor
double round = Math.round(-3.9999);
System.out.println("四舍五入:(round -3.9999)"+round);
//开方
double sqrt = Math.sqrt(9);
System.out.println("开方:(sqrt 9)"+sqrt);
}
}
2. ArrayList类
2.1 什么是ArrayList
java.util.ArrayList 是大小可变的数组实现,存储在内的数据称为元素。
此类提供一些方法来操作内部存储的元素。ArrayList中可不断添加元素,
其大小也自动增长。
2.2 ArrayList的使用步骤
- java.unit.ArrayList < E >:该类需要import导入的包。
< E >,表示一种指定的数据类型,