Strictfp Modifier in java | Access Modifiers in java-Pingjava
Strictfp Modifier in java
Strictfp:
1. strictfp is the modifier applicable for methods and classes but not for variables.
2. Strictfp modifier introduced in 1.2 versions.
3. Usually the result of floating point of arithmetic is varing from platform to platform,to overcome this problem we should use strictfp modifier.
4. If a method declare as the Strictfp then all the floating point calculations in that method has to follow IEEE754 standard, So that we will get platform independent results.
Example:
System.out.println(10.0/3);
P4 -------->3.33333333333333
P3 -------->3.333333
IEEE754 ---->3.333
If a class declares as the Strictfp then every concrete method(which has body) of that class has to follow IEEE754 standard for floating point arithmetic, so we will get platform independent results.
What is the difference between, abstract and strictfp ?
1. Strictfp method is about implementation where as abstract method never talks about implementation hence abstract, strictfp combination is illegal for methods.
2. But we can declare a class with abstract and strictfp modifier simultaneously. So from these,abstract strictfp combination is legal for classes but illegal for methods.
Example:
public abstract strictfp void methodOne(); (invalid)
abstract strictfp class Test (valid)
{
}
An Inspirational quote:
"Don’t Let Yesterday Take Up Too Much Of Today."
Happy Reading.Happy Learning!!! See you in next post :)
Post a Comment