Here’s an example I have.
public int getDelta()
{
long time = getTime();
int delta = (int) (time - lastFrame);
lastFrame = time;
return delta;
}
In the fourth line, there’s an “(int)”. What does it mean?
This code is just an example I found with it; I’m not looking for a specific answer to the code I posted. What the (int) even does, generally. I’ve seen it done with (byte) too.
It means you’re casting a long into an int. See: http://en.wikipedia.org/wiki/Type_conversion
You can’t just say
Because time and lastFrame are longs (I’m assuming lastFrame is, at least). Therefore you must convert the type (cast) the result of that subtraction into an integer value.