# 定义一个类Generator

<p>定义一个类 Generator&#xff08;生成器类&#xff09;&#xff0c;它可以在每次调用其 next()方法时&#xff0c;产生由你 最喜欢的电影&#xff08;如 Snow White 或 Star Wars&#xff09;的字符构成的名字&#xff08;作为 String 对象&#xff09;。在字 符列表中的电影名用完之后&#xff0c;循环到这个字符列表的开始处。使用这个生成器来填充数组、 ArrayList、LinkedList、HashSet&#xff0c;然后打印每一个容器。</p>

## template

```java
import java.util.*;
public class MovieGenerator {
	private String[] movies = new String[] { "SS", "DD", "HH", "FF", "XX", "ZZ" };
	private int i = 0;
	public String next() {
		return movies[i++ % movies.length];
	}
	public String[] getMovies() {
		return movies;
	}
	public Collection<String> fill(Collection<String> collection) {
		for (int i = 0; i < 8; i++) {
			collection.add(next());
		}
		return collection;
	}
	public static void main(String[] args) {
		MovieGenerator generator = new MovieGenerator();
		System.out.println(Arrays.toString(generator.getMovies()));
		System.out.println(generator.fill(new ArrayList<String>()));
		System.out.println(generator.fill(new LinkedList<String>()));
		System.out.println(generator.fill(new HashSet<String>()));
	}
}
```

## 答案

```java

```

## 选项

### A

```java

```

### B

```java

```

### C

```java

```