skill/Java.Kotlin

[Kotlin] 배열 만들기 List<Int>, List<String>

have a nice day :D 2022. 4. 27. 11:46
반응형

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
}
반응형