strictfp Keyword in Java programming

Java 8Object Oriented ProgrammingProgramming

strictfp is used to ensure that floating points operations give the same result on any platform. As floating points precision may vary from one platform to another. strictfp keyword ensures the consistency across the platforms.

strictfp can be applied to class, method or on interfaces but cannot be applied to abstract methods, variable or on constructors. Following are the valid examples of strictfp usage.

Example

strictfp class Test {
}
strictfp interface Test {
}
class A {
   strictfp void Test() {
   }
}

Example

Following are the invalid strictfp usage.

class A {
   strictfp float a;
}
class A {
   strictfp abstract void test();
}
class A {
   strictfp A() {
   }
}
raja
Published on 01-Nov-2018 06:50:18
Advertisements