Created
June 7, 2020 09:29
-
-
Save adryanev/629103fded7c6b03ca13ae1aec0cc6e4 to your computer and use it in GitHub Desktop.
Unary Operator, Increment, and Decrement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package operator_casting | |
class OperatorUnaryIncDec { | |
companion object { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
var bilanganSatu = -1 | |
var bilanganDua = 2 | |
val booleanSatu = true | |
var hasil: Int | |
var hasilBoolean: Boolean | |
// positif | |
hasil = +bilanganSatu | |
println("+($bilanganSatu) = $hasil") | |
//negatif | |
hasil = -bilanganSatu | |
println("-($bilanganSatu) = $hasil") | |
//negasi | |
hasilBoolean = !booleanSatu | |
println("!$booleanSatu = $hasilBoolean") | |
//increment | |
++bilanganSatu | |
println(bilanganSatu) | |
//decrement | |
--bilanganDua | |
println(bilanganDua) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment