提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
一元运算符,-,++
class UnaryDemo {/*来 自 nowjava - 时 代 Java*/ public static void main(String[] args) { int result = +1; // result is now 1 System.out.println(result); result--; // result is now 0 System.out.println(result); result++; // result is now 1 System.out.println(result); result = -result; // result is now -1 System.out.println(result); boolean success = false; // false /* nowjava - 时 代 Java */ System.out.println(success); // true System.out.println(!success); } }