摘要:
ArrayList集合 对象数组 题目:定义一个数组,用来存储3个Person对象。 public static void main(String[] args) { Person[] array = new Person[3]; Person one = new Person("迪丽热巴",18) 阅读全文
摘要:
Random类 概述和基本使用 Random 类用来生成随机数字。使用起来也是三个步骤: 导包 创建:Random r = new Random();//小括号留空即可 使用:获取一个随机的int数字(范围是int的所有的范围,有正负两种):int num = r.nextInt(); 获取一个随机 阅读全文
摘要:
匿名对象 使用方式 普通使用方式: Scanner sc = new Scanner(System.in);int num = sc.nextInt(); 匿名对象的方式: int num = new Scanner(System.in).nextInt();System.out.println(n 阅读全文