java.lang.reflect.Modifier的isStrict(mod)方法用于检查integer参数是否包含strictfp修饰符。如果此整数参数表示strictfp类型的修饰符,则方法返回true,否则返回false。
用法:
public static boolean isStrict(int mod)
参数:此方法接受整数名称,因为mod代表一组修饰符。
返回:如果mod包含strictfp修饰符,则此方法返回true;否则为假。
以下示例程序旨在说明isStrict()方法:
示例1:
// Java program to illustrate isStrict() method
import java.lang.reflect.*;
public class GFG {
public static void main(String[] args)
throws NoSuchFieldException,
SecurityException
{
// get Modifier Integer value
int mod = Test.class.getModifiers();
// check Modifier is strict or not
boolean result = Modifier.isStrict(mod);
System.out.println("Mod integer value "
+ mod + " is strict : "
+ result);
}
strictfp class Test {
strictfp double mul()
{
return 0;
}
}
}
输出:
Mod integer value 0 is strict : false
示例2:
// Java program to illustrate isStrict()
import java.lang.reflect.*;
public class GFG {
public static void main(String[] args)
throws NoSuchFieldException,
SecurityException
{
// get Modifier Integer value
int mod = interfaceTest
.class
.getModifiers();
// check Modifier is strict or not
boolean result
= Modifier.isStrict(mod);
System.out.println("Mod integer value "
+ mod + " is strict : "
+ result);
}
strictfp interface interfaceTest {
double method1();
int method2();
}
}
输出:
Mod integer value 1544 is strict : false