1.Scanner类(java.util.Scanner;)
* nextInt(); 用来接收控制台录入的数字.
* next(); 用来接收控制台录入的字符串.
2.Math类(java.lang.Math)
* public static int min(int a,int b) 求两个数的最小值
* public static int max(int a,int b) 求两个数的最大值
* public static long round(double a) 四舍五入
* public static double ceil(double a) 向上取整
* public static double floor(double a) 向下取整
3.String类
* public int length()用来返回字符串长度
* public String trim()用来去除字符串两端空白
* public String substring(开始索引,结束索引)用来截取 大字符串中小字符串的一部分,包含头不包含尾
4.Random类(java.util.Random)
* public int nextInt(int maxValue) 产生[0,maxValue)范 围的随机整数,包含0,不包含maxValue;
* public double nextDouble() 产生[0,1)范围的随机小数, 包含0.0,不包含1.0
5.System类
* exit(int status) 方法用来终止当前正在运行的Java虚拟 机,其中的参数status用于表示当前发生的异常状态,通常 指定为0,表示正常退出,否则表示异常终止
6.ArrayList类(java.util.ArrayList)
* ArrayList<Object> list = new ArrayList<>();
* boolean add(Object obj) 将指定元素追加到集合末尾
* Object get(int index) 返回集合中指定位置的元素
* int size() 返回集合中的元素数量
* boolean add(int index, Object obj)在集合中指定 index位置,添加新元素obj
* Object set(int index, Object obj)用指定元素obj替 代集合中指定index位置的元素
* Object remove(int index)从集合中删除指定index处的 元素,返回该元素
* void clear()清空集合中所有元素
持续更新中....
|
|