Assign smaller number to variable in 1 line
Is there a one-liner for this function?
int side = width &l开发者_Python百科t; height ? width : height;
width = side;
height = side;
width = height = width < height ? width : height;
It is possible:
width = height = width < height ? width : height;
However it's generally not the convention in Java to assign multiple variables on one line.
width = height = Math.min(width, height);
height = width = width < height ? width : height;
精彩评论