用java编译程序将我爱你存入数组然后正着和反着输出
代码如下:
public class Main {
public static void main(String[] args) {
String[] arr = {"我", "爱", "你"};
// 正着输出
for (String s : arr) {
System.out.print(s + " ");
}
System.out.println();
// 反着输出
for (int i = arr.length - 1; i >= 0; i--) {
System.out.print(arr[i] + " ");
}
System.out.println();
}
}
输出结果为:
我 爱 你
你 爱 我
原文地址: http://www.cveoy.top/t/topic/drl6 著作权归作者所有。请勿转载和采集!