반응형
List<Int>, List<String>의 배열 생성
fun main() {
println(mutableListOf(1,2,3))
println(mutableListOf("가", "나", "다"))
}
배열의 가장 큰 숫자 조회
object Util {
fun getBigger(list: List<Int?>): Int {
var result = 0
for(count in list) {
if(count != null && result < count) {
result = count
}
}
return result
}
}
fun main() {
println(Util.getBigger(mutableListOf(1, 2, 3))) // 3
}
반응형
'skill > Java.Kotlin' 카테고리의 다른 글
Springboot request param VO class로 받을 시, 필수 값 null일 경우 exception handler 처리 (0) | 2023.02.01 |
---|---|
Springboot @RequestParam null 일 경우, exception handler 처리 (0) | 2023.01.31 |
Kotlin Scheduler (batch) (0) | 2022.02.07 |
[SpringBoot] Completed 405 METHOD_NOT_ALLOWED Error 해결 (0) | 2021.06.12 |
JPA PK 자동 증가일 경우, 등록 방법 (0) | 2021.05.12 |