一个for循环,用用户输入的字符串填充玩家名称数组。
import java.util.Scanner; public class Main { /** from n o w j a v a . c o m**/ public static void main(String[] args) { int count = 10; String[] players = new String[count]; Scanner sc = new Scanner(System.in); for (int i = 0; i < count; i++) { System.out.print("Enter player name: "); players[i] = sc.nextLine(); // sc is a Scanner } } }