Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does suffix 'f' mean in Java code?

Tags:

java

Here's the explanatory code. The language is Java and the code uses Android.

fg.setTextSize(height*0.50f); //<-'f' is in the brackets

or

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    sWidth = w / 3f; // <-'f' is here
}

What does the suffix 'f' mean?

like image 683
sandalone Avatar asked Jan 11 '11 15:01

sandalone


4 Answers

It indicates a float literal.

like image 60
Phil Hunt Avatar answered Nov 15 '22 05:11

Phil Hunt


It indicates 3 is float not integer in other case 0.50 is float not double. Just like in any other java program.

like image 45
Tasawer Khan Avatar answered Nov 15 '22 05:11

Tasawer Khan


float ;)

it's a 3 that is a float, not an int

like image 29
Nanne Avatar answered Nov 15 '22 04:11

Nanne


It's a float, not a double. This is basic Java (C) notation.

like image 2
Pontus Gagge Avatar answered Nov 15 '22 06:11

Pontus Gagge