2

I am confused by the 'f'.

ObjectAnimator moveUp = ObjectAnimator.ofFloat(ivLogo, "translationY", 0f, -150f);
    moveUp.setDuration(1000);
    moveUp.setStartDelay(500);
    moveUp.start();

What's the meaning of 'f'?And what's the meaning of form 'of' to '-150f'?

3 Answers3

2

The 'f' means that the -150 is a float type, not a value by itself

moictab
  • 959
  • 6
  • 27
2

It's a floating point literal. https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.10.2

0f means that 0 is float

Kirill Akhmetov
  • 318
  • 4
  • 12
2

That f is needed because the parameter type the function expects is float. And that is the way of converting 0 (which is integer) to float.

See here

Also using d and L will give you double and long type respectively (just in case if you see them any other place.)

Nabin
  • 11,216
  • 8
  • 63
  • 98