Discuss / Java / 按倒序遍历数组并打印每个元素

按倒序遍历数组并打印每个元素

Topic source

Afu

#1 Created at ... [Delete] [Delete and Lock User]
int[] ns = {
    1, 4, 9, 16, 25
};
// 倒序打印数组元素:
for (int i = ns.length - 1; i >= 0; i--) {
    System.out.println(ns[i]);
}

  • 1

Reply