package com.Summer_0420.cn; /**
* @author Summer
* 获取数值型数组中大于60的元素个数
* 给数值型数组中不足60分的加20分
*/
public class TestMethod02 { public static void main(String[] args) {
int [] a = {1,35,60,80,75,123,156,32,1};
show(a); } private static void show(int[] a) {
int count = 0;
for (int i = 0; i < a.length; i++) {
if (a[i]>60) {
count++;
} else {
a[i]+=20;
}
}
for (int i : a) {//增强型for循环能查看所有元素,但不能修改
System.out.print(i+" ");
}
System.out.println("大于60的元素数量"+count); } }