public class Test002 {
public static void main(String[] args) {
int n[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
System.out.println("숫자들의 합 : " + sum(n));
}
public static int sum(int[] numbers) {
int total=0;
int i;
for(i=0; i<numbers.length; i++)
total += numbers[i];
return total;
}
}
댓글 없음:
댓글 쓰기