티스토리 뷰
for-each
for (Type obj : Collection) {...}
example
for (CustomInfo c : customManagers) {
System.out.println(c.toString());
}
works only if the collection holds elements of type Type.
public class Main{ public static void main(String[] args) { int[] arr = new int[]{ 1,2,3,4,5 }; //for-each. normally used for iterating Arrays or Collection
for (int i : arr) { System.out.print(i); //12345 } System.out.println(""); //normal for loop
for (int i = 0; i<arr.length; i++) { int var = arr[i]; System.out.print(var); //12345 } } }
|
'JAVA' 카테고리의 다른 글
Error: could not find or load main class Main (0) | 2019.07.19 |
---|---|
Serialization example code in java (0) | 2019.07.17 |
Returning ArrayList from Method (0) | 2019.07.13 |
Iterator (0) | 2019.07.12 |
Check only integer input (0) | 2019.07.12 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- java
- easy javascript algorithm
- HackerRank Algorithm
- math.abs
- rest parameter
- equals()
- code refactoring
- spring boot application
- repeat()
- javascript
- algorithm
- Javascript Algorithm
- math.max
- hackerrank solution
- 프로그래머스 알고리즘
- ... in Javascript
- hackerrank
- 프로그래머스
- hackerrank javascript
- compareTo()
- easy algorithm
- C++
- string class in java
- HashMap
- hackerrank javascript solution
- Collection Framework
- substring()
- Object type casting
- 프로그래머스 알고리즘문제
- 알고리즘
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
글 보관함