三元表达式的使用-判单一个变量是否为空

今天在写项目的时候,写了一个三元表达式,刚写完分号,就显示红色的波浪线。郁闷。。。。。。

错误: 

String tIdType=tLPBnfSchema.getIDType();
tIdType==null ?(""):tIdType;


正确:

String tIdType=tLPBnfSchema.getIDType();
tIdType=(tIdType==null) ?(""):tIdType;

猜你喜欢

转载自www.cnblogs.com/dongyaotou/p/11924192.html