double[] ar = {1.2, 3.0, 0.8};
int sum = 0;
for (double d : ar) { // d gets successively each value in ar.
sum += d;
}
And here is the same loop using the basic for. It requires an extra iteration variable.
double[] ar = {1.2, 3.0, 0.8};
int sum = 0;
for (int i = 0; i < ar.length; i++) { // i indexes each element successively.
sum += ar[i];
}
'java' 카테고리의 다른 글
JPA DATA TO DTO TO JSON ( Modelmapper & lombock ) (0) | 2019.07.20 |
---|---|
JAP intelli sence 자동 완성 기능 안될시. (0) | 2019.07.18 |
AOP 로그출력 ( Message Advice ) (0) | 2019.07.15 |
IntelliJ Shortcut (0) | 2019.07.13 |
Javascript Destructuring assignment( 비구조화 할당 ) (0) | 2019.07.12 |
댓글