Java Strictfp keyword


In Java language, Strictfp Keyword helps to get identical results for every platform.In the floating-point value, precision may differ from platform to platform. In that situation the strictfp keyword which helps to get the same result on every platform.

Java strictfp

An interface or a class is declared with strictfp modifier, then all methods declared in the class/interface, and all nested types declared in the class, are implicitly strictfp.


Syntax:-

 strictfp class Cricket{}//strictfp class 

class Cricket
{  
	strictfp void Team(){}//strictfp method  
} 

 strictfp interface Captian{}//strictfp interface  

Example:-

strictfp class Cal
{  
	double amt=60;  
	void interest(Cal cv){  
		cv.amt=cv.amt+7.2; 
	} 
}
public class Calculation{
	public static void main(String args[])
    {  
		Cal cv=new Cal();  
		System.out.println("Before Interest Amount "+cv.amt);  
		cv.interest(cv);
		System.out.println("After Interest Amount "+cv.amt);  
	}  
} 

notepad

The strictfp keyword cannot be used with abstract methods, variables or constructors.




Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.