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 a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.