/** Prints the given [message] and the line separator to the standard output stream. */
@kotlin.internal.InlineOnly
public actual inline fun println(message: Any?) {
    System.out.println(message)
}

출처: 초보자를 위한 코틀린(Kotlin) 200제 / 엄민석 지음 | 정보문화사 | 2018년 05월 20일 출간

package com.practice016

fun main(args: Array<String>): Unit
{
	val num: Int
	num = 15

	println(
			num + 7 * 3
	)	// 한문장이다, 출력: 36
}

 

출력

36

print 문(출력), println 문( 출력, 개행)는 괄호() 인식하여 내부 값을 출력 한다.

/** Prints the given [message] and the line separator to the standard output stream. */
@kotlin.internal.InlineOnly
public actual inline fun println(message: Any?) {
    System.out.println(message)
}

출처: 초보자를 위한 코틀린(Kotlin) 200제 / 엄민석 지음 | 정보문화사 | 2018년 05월 20일 출간

배정연산자 Assignment Operator: 변수에 값을 저장할 때 사용하는 연산자

package com.practice015

// 배정연산자 Assginment Operator: 변수에 값을 저장할때 사용하는 연산자
fun main(args: Array<String>): Unit
{
	val a: Int
	var b: Int

	a = 10 + 5
	b = 10

	b += a // b에 a의 값을 누적
	println(b)	// 출력: 25

	b %= 3 // b를 3으로 나눈 나머지를 b에 저장
	println(b)	// 출력 : 1
}

 

출력

25
1

 

참고 :  https://kotlinlang.org/docs/reference/grammar.html#precedence

 

Grammar

 

kotlinlang.org

출처: 초보자를 위한 코틀린(Kotlin) 200제 / 엄민석 지음 | 정보문화사 | 2018년 05월 20일 출간

package com.practice014
// 주석

fun main(args: Array<String>): Unit
{
	// Apple을 화면에 출력한다.
	println(/* 이 부분은 컴파일러가 통째로 무시한다. */"Apple"/* 이
	부
	분
	도
	*/)
}

 

주석Comment:  소스코드가 자연어가 아니기때문에 설명하기 위한 문법

// 이렇게도 /* 주석내용  */ 또는 이렇게도 사용 가능

출력:

Apple

 

+ Recent posts