๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
728x90

2023 ์•ˆ๋“œ๋กœ์ด๋“œ23

์ฒซ ๋ฒˆ์งธ Android ์•ฑ ๋งŒ๋“ค๊ธฐ 5 5) ํ…์ŠคํŠธ ์—…๋ฐ์ดํŠธ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { GreetingCardTheme { // A surface container using the 'background' color from the theme Surface( modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background ) { Greeting("Android") } } } } } onCreate() ํ•จ์ˆ˜๋Š” ์ด ์•ฑ์˜ ์ง„์ž…์ ์œผ๋กœ ๋‹ค๋ฅธ ํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ.. 2022. 11. 15.
์—ฐ์Šต๋ฌธ์ œ ๋ฉ”์‹œ์ง€ ์ธ์‡„ fun main() { println("Use the val keyword when the value doesn't change.") println("Use the var keyword when the value can change.") println("When you define a function, you define the parameters that can be passed to it.") println("When you call a function, you pass arguments for the parameters.") } ์ปดํŒŒ์ผ ์˜ค๋ฅ˜ ์ˆ˜์ • fun main() { println("New chat message from a friend'} } fun main() { println(".. 2022. 11. 15.
์•ˆ๋“œ๋กœ์ด๋“œ ์Šคํ„ฐ๋”” 1์ผ์ฐจ ๊ณผ์ œ unit1 Mainํ•จ์ˆ˜ mainํ•จ์ˆ˜๋ž€ ์ฝ”๋“œ์—์„œ Kotlin ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ์‹œ์ž‘๋˜๋Š” ํŠน์ • ์œ„์น˜์ž…๋‹ˆ๋‹ค. mainํ•จ์ˆ˜๋Š” ํ”„๋กœ๊ทธ๋žจ์˜ ์ง„์ž…์  ๋˜๋Š” ์‹œ์ž‘์ ์ž…๋‹ˆ๋‹ค. ํ•จ์ˆ˜๋ž€? Kotlin ์Šคํƒ€์ผ ๊ฐ€์ด๋“œ ํ•จ์ˆ˜์˜ ์ด๋ฆ„์€ ์นด๋ฉœ ํ‘œ๊ธฐ๋ฒ•์œผ๋กœ!, ๋™์‚ฌ ๋˜๋Š” ๋™์‚ฌ๊ตฌ ๊ฐ ๋ฌธ์€ ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ์ž…๋ ฅ ์—ฌ๋Š” ์ค‘๊ด„ํ˜ธ๋Š” ํ•จ์ˆ˜๊ฐ€ ์‹œ์ž‘๋˜๋Š” ์ค„์˜ ๋์— ํ‘œ์‹œ ์—ฌ๋Š” ์ค‘๊ด„ํ˜ธ ์•ž์—๋Š” ๊ณต๋ฐฑ์ด ์žˆ์–ด์•ผ ํ•œ๋‹ค. ํ•จ์ˆ˜ ๋ณธ๋ฌธ ์ž‘์„ฑ ์‹œ Tab์œผ๋กœ ๋“ค์—ฌ์“ฐ๊ธฐ ํ•˜์ง€ ๋ง ๊ฒƒ! ๊ณต๋ฐฑ 4๊ฐœ๋ฅผ ์ž…๋ ฅํ•˜๊ธฐ ๋‹ซ๋Š” ์ค‘๊ด„ํ˜ธ๋Š” ํ•จ์ˆ˜ ์‹œ์ž‘๋ถ€๋ถ„์— ์žˆ๋Š” funํ‚ค์›Œ๋“œ๋กœ ์ •๋ ฌ๋˜๋„๋ก ํ•˜๊ธฐ fun main() { println("Hello, world!") } 2022. 11. 15.
Kotlin์—์„œ ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ ๋ฐ ์‚ฌ์šฉํ•˜๊ธฐ mainํ•จ์ˆ˜๋Š” ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ์‹œ์ž‘์ ์œผ๋กœ ์‚ฌ์šฉ ํ•จ์ˆ˜ ์ •์˜ fun ํ•จ์ˆ˜๋ช…() { } ๋ฐ˜ํ™˜๊ฐ’์ด ์žˆ๋Š” ๊ฒฝ์šฐ 1)Unit ๋ฐ˜ํ™˜ ์œ ํ˜• ์•„๋ฌด๊ฒƒ๋„ ๋ฐ˜ํ™˜ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ 2) String์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ์œ ํ˜• ํ•˜๋‚˜์˜ ํ•จ์ˆ˜๋Š” ์˜ค์ง ํ•˜๋‚˜์˜ ๋ฌธ์ž์—ด๋งŒ ๋ฐ˜ํ™˜ ๊ฐ€๋Šฅ ๋ ค fun main() { println(birthdayGreeting()) } fun birthdayGreeting(): String { val nameGreeting = "Happy Birthday, Rover!" val ageGreeting = "You are now 5 years old" return "$nameGreeting\n$ageGreeting" } birthdayGreeting ํ•จ์ˆ˜์— ๋งค๊ฐœ๋ณ€์ˆ˜ ์ถ”๊ฐ€ํ•˜๊ธฐ ํ•˜๋‚˜์˜ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๋ณ€์ˆ˜์ด๋ฆ„๊ณผ ๋ฐ์ดํ„ฐ ์œ ํ˜•์œผ๋กœ ๊ตฌ์„ฑ๋˜๋ฉฐ, :(์ฝœ.. 2022. 11. 14.
728x90