在JAVA中,将以下代码转换为使用三元运算符的最佳方法是什么:
if (input > 0) { result1 = input; result2 = input; } else { result1 = -1; result2 = -1; }
简短:
result1 = result2 = input > 0 ? input : -1;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
点击生成二维码
我来说两句