-5
String[] options = { "3 km/hr", "5 km/hr", "8 km/hr", "9 km/hr" };
4

2 回答 2

1

您可以迭代数组并自己“显示”每个元素,也可以使用Arrays.toString(options)它来创建格式良好的字符串表示。

于 2013-02-17T09:58:25.157 回答
0

如果您想知道如何打印这些值,您可以尝试:

    String[] options = { "3 km/hr", "5 km/hr", "8 km/hr", "9 km/hr" };
    System.out.println(Arrays.toString(options));
    --> the output would be: [3 km/hr, 5 km/hr, 8 km/hr, 9 km/hr]

或者你可以手动完成,使用:

    for (String option : options) {
        System.out.println(option);
    }
    --> the output would be:
    3 km/hr
    5 km/hr
    ...etc
于 2013-02-17T10:02:05.890 回答