Java Strictfp Keyword

Java strictfp keyword ensures that you will get the same result on every platform if you perform operations in the floating-point variable. The precision may differ from platform to platform that is why java programming language have provided the strictfp keyword, so that you get same result on every platform. So, now you have better control over the floating-point arithmetic.

Legal code for strictfp keyword

The strictfp keyword can be applied on methods, classes and interfaces.

Example #1
snippet
strictfp class A{}//strictfp applied on class
Example #2
snippet
strictfp interface M{}//strictfp applied on interface
Example #3
snippet
class A{
strictfp void m(){}//strictfp applied on method
}

Illegal code for strictfp keyword

The strictfp keyword cannot be applied on abstract methods, variables or constructors.

Example #1
snippet
class B{
strictfp abstract void m();//Illegal combination of modifiers
}
Example #2
snippet
class B{
strictfp int data=10;//modifier strictfp not allowed here
}
Example #3
snippet
class B{
strictfp B(){}//modifier strictfp not allowed here
}
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +