티스토리 뷰
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
- ... in Javascript
- javascript
- hackerrank
- HashMap
- 프로그래머스
- 프로그래머스 알고리즘문제
- easy javascript algorithm
- HackerRank Algorithm
- hackerrank solution
- string class in java
- compareTo()
- Object type casting
- math.max
- Collection Framework
- hackerrank javascript solution
- rest parameter
- C++
- 알고리즘
- code refactoring
- hackerrank javascript
- easy algorithm
- math.abs
- 프로그래머스 알고리즘
- Javascript Algorithm
- equals()
- spring boot application
- algorithm
- substring()
- repeat()
- java
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함