forked from txs72/JavaTutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh12Q03.java
More file actions
executable file
·30 lines (28 loc) · 991 Bytes
/
Ch12Q03.java
File metadata and controls
executable file
·30 lines (28 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* */ package ch12;
/* */
/* */ import java.util.Random;
/* */ import java.util.Scanner;
/* */
/* */ public class Ch12Q03 {
/* */ public static void main(String[] args) {
/* 8 */ int[] numbers = new int[100];
/* 9 */ Random r = new Random();
/* 10 */ for (int i = 0; i < numbers.length; i++) {
/* 11 */ numbers[i] = r.nextInt();
/* */ }
/* 13 */ Scanner scanner = new Scanner(System.in);
/* */ while (true) {
/* 15 */ System.out.print("Please input an index: ");
/* 16 */ int input = scanner.nextInt();
/* */ try {
/* 18 */ System.out.println(numbers[input]);
/* 19 */ } catch (ArrayIndexOutOfBoundsException e) {
/* 20 */ System.out.println("Out of bounds.");
/* */ }
/* */ }
/* */ }
/* */ }
/* Location: /Volumes/TXS.128G/hope useful/practice/2020.jar!/ch12/Ch12Q03.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/