操作符重载


加符号+ - !

>

    var a = 1
    var b = a.unaryMinus()
    var c = b.unaryMinus()
    var d = b.unaryPlus()
    println("a = $a , b = $b , c = $c , d = $d")

    var isW = true
    println("isW = $isW and !isW = ${isW.not()}")

    /**
    a = 1 , b = -1 , c = 1 , d = -1
    isW = true and !isW = false
    */

++,--

和java一样的

算术

+,-,x,/,%,.. 还有对应的方法,省略

其他

其他操作都和java差不多的,可能有细微的差别,用的时候细看吧

results matching ""

    No results matching ""