26 |
|
* @bug 4339792 |
27 |
|
* @summary Basic test for Collections.disjoint |
28 |
|
* @author Josh Bloch |
29 |
< |
* |
30 |
< |
* @compile -source 1.5 Disjoint.java |
31 |
< |
* @run main Disjoint |
29 |
> |
* @key randomness |
30 |
|
*/ |
31 |
|
|
32 |
< |
import java.util.*; |
32 |
> |
import java.util.ArrayList; |
33 |
> |
import java.util.Collections; |
34 |
> |
import java.util.HashSet; |
35 |
> |
import java.util.List; |
36 |
> |
import java.util.Random; |
37 |
|
|
38 |
|
public class Disjoint { |
39 |
|
static final int N = 20; |
40 |
|
|
41 |
< |
public static void main(String args[]) { |
41 |
> |
public static void main(String[] args) { |
42 |
|
// Make an array of lists each of which shares a single element |
43 |
|
// with its "neighbors," and no elements with other lists in the array |
44 |
|
Random rnd = new Random(); |
46 |
|
int x = 0; |
47 |
|
for (int i = 0; i < N; i++) { |
48 |
|
int size = rnd.nextInt(10) + 2; |
49 |
< |
List<Integer> list = new ArrayList<Integer>(size); |
49 |
> |
List<Integer> list = new ArrayList<>(size); |
50 |
|
for (int j = 1; j < size; j++) |
51 |
|
list.add(x++); |
52 |
|
list.add(x); |