如何制作两个大小相同的数组列表
就像当我在第一个数组列表中的索引 5 处停止时,第二个数组列表将在我到达索引 5 时自动停止
import java.util.*;
public class test {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
ArrayList <String> title = new ArrayList<>();
ArrayList <String> description = new ArrayList<>();
int i = 0;
int d = 0;
String n = in.nextLine();
while(!n.equals(" ")){
System.out.println("Enter a movie title");
title.add(n);
n = in.nextLine();
}
for(;i < title.size(); i++){
System.out.println("[" + i+"]" +title.get(i));
}
description = new ArrayList<>(title.size());
String m = in.nextLine();
while(!m.equals(" ")){
System.out.println("Enter the movie Description");
description.add(m);
m = in.nextLine();
}
description.remove(0);
for(;d < description.size(); d++){
System.out.println("Description for ["+d+"]"+title.get(d)+":"+description.get(d) );
}
}
}
小唯快跑啊
holdtom
相关分类