最近遇到了一个问题,使用三元运算符:
map.put("money", money % 1.0 == 0 ? money.intValue() : money );
其中的money为Double类型,但是出现money % 1.0 == 0为true时,返回的类型依然为Double类型,而不是money.intValue() 中的int类型。
if (money % 1.0 == 0) {
map.put("money", money.intValue()); } else {
map.put("money", money); }
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177198.html原文链接:https://javaforall.net
