Java中的API

待施工

111

API:
Scanner
Random
String
StringBuilder
ArrayList
集合详解:

import java.util.ArrayList
构造方法public ArrayList()
添加方法,E指的是泛型
public boolean add(E element)
public void add(int index, E element)

Math
System
二者没有构造方法,不能创建对象,为啥设计成这样。

因为这个类内的方法非常常用,所以我们会把这样的类叫做工具类,
为了不让人创建对象来用,用private修饰构造方法,则只可以用类名调用。
把所有方法设定为static来使用,防止一些不懂的人创建对象。

Object
重写:
toString:
为什么String StringBuilder ArrayList这三个打印的是内容,其他的打印地址。

<IMG src="file:///C:\Users\Maomao\AppData\Roaming\feiq\RichOle\3366526921.bmp">	
	
	
equals:	

Math:
1. abs:
int abs(int num) //absolute 绝对值
System.out.println(Math.abs(-10));//10
2. ceil:
double ceil(double a);//求天花板(ceil)数,向上取整
System.out.println(Math.ceil(-10.9));//-10.0
3. floor:
double ceil(double a);//求地板(floor)数,向下取整
System.out.println(Math.ceil(-10.9));//-11.0
4. round:

5. random:
	Random r = new Random();
	return r.nextInt();//nextInt(100);
	
	
System类
posted @ 2019-11-15 10:57  卯毛  阅读(264)  评论(0编辑  收藏  举报