자바(Java)에서 for문 사용 예문
//예문1)
String[] numbers = {"one", "two", "three"};
for (int i=0; i<numbers.length; i++) {
LOGGER.debug(">>>:"+numbers[i]);
}
//예문2)
String[] numbers = new String[] {"a", "b", "c", "d"};
for (String number : numbers) {
LOGGER.debug(">>>:"+number);
}
//예문3)
List<ContentsVO> contentsList = contentsService.selectContentsList();
int index = 0;
for (ContentsVO contents : contentsList) {
LOGGER.debug(">>>index:"+index);
LOGGER.debug(">>>name:"+contents.getName());
index++;
}
//예문4)
List<ContentsVO> contentsList = contentsService.selectContentsList();
for (Iterator<ContentsVO> iter = contentsList.iterator(); iter.hasNext();) {
ContentsVO contents = iter.next();
LOGGER.debug(">>>:"+contents.getSeq());
}