今天在看spring security源码时,有这么一段代码:
public UserDetails build() {
String encodedPassword = (String)this.passwordEncoder.apply(this.password);
return new User(this.username, encodedPassword, !this.disabled, !this.accountExpired, !this.credentialsExpired, !this.accountLocked, this.authorities);
}
其中!this.disabled
没有初始化就直接取反,想着打印输出下结果看下是什么?输出结果为true
.在这里取反,默认值是false
吗?
验证下:
public class PrimitiveTypeTest {
private boolean v;
public boolean getV(){
return this.v;
}
public static void main(String[] args) {
System.out.print(new PrimitiveTypeTest().getV());
}
}
输出结果为false
来自为知笔记(Wiz)
标签:java,String,取反,disabled,false,默认值,public,布尔 From: https://www.cnblogs.com/baiyifengyun/p/16735945.html