발전/개인공부

for문 조건식 콜론기능(:)

Naramji 2022. 10. 14. 00:53

 

Q1.  for문의 조건식 안에 콜론(:)의 기능?

int index = 0;
		for(int num : score) {
			System.out.println(names[index] + ": " + num + "점");
			index++;
			sum += num;
		}

 

 

A1.  score에 있는 객체를 꺼내서 int num에 넣는다는 뜻!!

출처 :  https://m.blog.naver.com/kokolisy/110121503035