Java int equation inconsistent?

This drives me crazy because it completely violates my efforts to remove it:

int k = keyCode; //keyCode being a variable declared by a keyPress
//in the Processing library
//k and keyCode are working properly.
if ((k - UP)*500 == 0); //int UP=38;
{
 println((k-UP)*500 == 0);
 //some other code here
}

result? "False" (and delete '= = 0', a non-zero number) As far as I know, only when you use the arrow keys (k = = 37,38,39,40; 38 is up) can this condition be true

Are there any such inconsistencies and what may be the reasons? (the strange format of the condition is because it solves a similar problem. The right key does not work properly, only k = = right)

Solution

You have a semicolon after if, so always execute println

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>