Modifiers constructorModifiers() method in Java with Examples
The constructorModifiers() method of java.lang.reflect.Modifier class is used to get an integer value together with the modifiers of source language that can be applied to a constructor.
Syntax:
public static boolean constructorModifiers()
Parameters: This method accepts nothing.
Return: This method returns an int value OR-ing together the source language modifiers that can be applied to a constructor.
Below programs illustrate constructorModifiers() method:
Program 1:
// Java program to illustrate // constructorModifiers() method import java.lang.reflect.*; public class GFG { public static void main(String[] args) throws NoSuchFieldException, SecurityException { // get Modifier using constructorModifiers() int result = Modifier.constructorModifiers(); System.out.println( "Constructor Modifiers: " + Modifier.toString(result)); } } |
Output:
Constructor Modifiers: public protected private
Program 2:
// Java program to illustrate // constructorModifiers() import java.lang.reflect.*; public class GFG { public static void main(String[] args) throws NoSuchFieldException, SecurityException { // get Modifier // using constructorModifiers() int result = Modifier.constructorModifiers(); System.out.println( "Int Value: " + result); } } |
Output:
Int Value: 7
References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Modifier.html#constructorModifiers()
Please Login to comment...