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