可以使用三目运算符来简化代码:

if ((oldValue == null && newValue != null) || (oldValue != null && !oldValue.equals(newValue))) {
    differentColumns.add(column);
}

这样可以将三个 if 语句合并为一个,同时也更加清晰和简洁。

Java 代码优化:使用三元运算符简化 if 语句