[英]Role of decrement operator in the following statement?
Going through a solution for a problem I'm trying to solve and I am not able to understand how the decrement operator works in the following statement.通过解决我试图解决的问题,我无法理解递减运算符在以下语句中的工作原理。
if (--degree[j] == 0) bfs.add(j);
Write some simple code to confirm what you think写一些简单的代码来确认你的想法
int arr[] = {1};
if (-- arr[0] == 0) {
System.out.println("true");
}
// and again
if (-- arr[0] != 0) {
System.out.println("true");
}
output output
true
true
import java.util.Arrays;
import static java.lang.System.*;
public class Main {
public static void main(String[] args) {
boolean thrown = false;
int[] arr = new int[]{1};
--arr[0];
out.println("true");
if (-- arr[0] != 0) out.println("true");
}
}
**Output ** **输出 **
true
true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.