API(Scanner、Random、ArrayList)

Scanner

import java.util.Scanner;
/*
public int nextInt(): to get a integer from keyboard
public String next(): to get a string from keyboard,end with space;

Scanner sc = new Scanner(System.in);

*/

Random

import java.util.Random;

// 构造方法:
//  public Random():创建一个新的随机数生成器;
// 成员方法:
//  public int nextInt(int bound):产生0~n的随机数,但是不包括n
    

ArrayList

import java.util.ArrayList

// 构造方法:
//  public ArrayList():构造一个内容为空的集合
// 基本格式:
//  ArrayList<String> StringList = new ArrayList<>();
//  ArrayList<int> intList = new ArrayList<>();
// 成员方法:
//  public boolean add(E e):在集合中加入元素到尾部
//  public E remove(int index):删除指定位置上的元素,并且返回被删除元素;
//  public E get(int index):获取指定位置上的元素,并且返回;
//  public int size():返回几个元素的个数。

猜你喜欢

转载自www.cnblogs.com/zhuobo/p/10598754.html