본문 바로가기
Backend

Kotlin

by 희디 2023. 9. 20.

read-only variables : val   // 편집 불가 

mutable variable : var      // 편집 가능 

 

val을 디폴트로 하는 것이 좋다.

 

String templates

val customers = 14
println("There are $customers customers")
// There are 14 customers

println("There are ${customers + 1} customers")
// There are 15 customers

$으로 변수를 설정해서 출력할 수 있다. 

 

// 변수 초기화없이 선언을 
val d : Int 
// 변수 초기화 
d = 3

// 타입을 명시하고 초기화 
val e : String = "hello"

 

'Backend' 카테고리의 다른 글

AWS EC2로 배포하기 (feat. WSL)  (0) 2025.03.02
4주차 ERD 설계 및 RDS 만들기  (0) 2023.10.08
3주차  (0) 2023.09.30
IP 주소와 포트번호  (0) 2023.09.18
서버란 무엇인가(소켓 & 멀티 프로세스)  (0) 2023.09.17