java.lang.reflect.Parameter Class in Java Last Updated : 31 Mar, 2022 Comments Improve Suggest changes Like Article Like Report java.lang.reflect.Parameter class provides Information about method parameters, including their name and modifiers. It also provides an alternate means of obtaining attributes for the parameter. Some useful methods of Parameter class are: public int getModifiers(): It returns the modifier flags for the parameter represented by this Parameter object.public String getName(): It returns the name of the method parameter.public Type getParameterizedType(): It returns the type of the parameter. All the methods of java.lang.reflect.Parameter class is listed below as follows: MethodDescriptionequals(Object obj)Compares based on the executable and the index.getAnnotatedType()Returns an AnnotatedType object that represents the use of a type to specify the type of the formal parameter represented by this Parameter.getAnnotation(Class<T> annotationClass)Returns this element's annotation for the specified type if such an annotation is present, else null.getAnnotations()Returns annotations that are present on this element.getAnnotationsByType(Class<T> annotationClass)Returns annotations that are associated with this element.getDeclaredAnnotations()Returns annotations that are directly present on this element.getDeclaredAnnotation(Class<T> annotationClass)Returns this element's annotation for the specified type if such an annotation is directly present, else null.getDeclaringExecutable()Return the Executable which declares this parameter.getDeclaredAnnotationsByType(Class<T> annotationClass)Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.getModifiers()Get the modifier flags for this parameter represented by this Parameter object.getName()Returns the name of the parameter.getParameterizedType()Returns a Type object that identifies the parameterized type for the parameter represented by this Parameter object.getType()Returns a Class object that identifies the declared type for the parameter represented by this Parameter object.hashCode()Returns a hash code based on the executable's hash code and the index.isImplicit()Returns true if the parameter is implicitly declared in the source code else returning false isNamePresent()Returning true if the parameter has the name in accordance with the class file isVarArgs()Returning true if this parameter represents a variable argument list.isSynthetic()Returning true if a parameter is not implicitly nor explicitly declared else falsetoString()Returns a string describing this parameter Example: Java // Java program to illustrate Parameter class of // java.lang.reflect package // Importing java.lang.reflect package to // obtain reflective information about classes and objects import java.lang.reflect.*; // Class 1 // Helper class class Calculate { // Function 1 // To add to numbers int add(int a, int b) { // Returning the sum return (a + b); } // Function 2 // To multiply two numbers int mul(int a, int b) { // Returning the number obtained // after multiplying numbers return (b * a); } // Function 3 // Subtracting two numbers long subtract(long a, long b) { // Return the numbers after subtracting // second number from the first number return (a - b); } } // Class 2 // Main class public class GFG { // Main driver method public static void main(String[] args) { // Creating object of helper class // in the main method Class cls = Calculate.class; // Getting all the methods of // a particular class Method[] methods = cls.getDeclaredMethods(); // Iterating over each method // using the for each loop for (Method method : methods) { // Print and display the method name // using getName() method System.out.print( "Method Name: " + method.getName() + " "); // Getting all the parameters of // a particular method Parameter parameters[] = method.getParameters(); // Print and display System.out.println("\nparameters of " + method.getName() + "() methods: "); // Iterating over parameters // using for each loop for (Parameter parameter : parameters) { // Display the type of parameters System.out.print( parameter.getParameterizedType() + " "); // Print the parameters of method System.out.print(parameter.getName() + " "); } // New line System.out.print("\n\n"); } } } OutputMethod Name: subtract parameters of subtract() methods: long arg0 long arg1 Method Name: add parameters of add() methods: int arg0 int arg1 Method Name: mul parameters of mul() methods: int arg0 int arg1 Comment More infoAdvertise with us Next Article java.lang.reflect.Parameter Class in Java K kapilnama1998 Follow Improve Article Tags : Java java-lang-reflect-package Practice Tags : Java Similar Reads java.lang.reflect.Method Class in Java java.lang.reflect.Method class provides necessary details about one method on a certain category or interface and provides access for the same. The reflected method could also be a category method or an instance method (including an abstract method). This class allows broadening of conversions to oc 3 min read java.lang.reflect.Proxy Class in Java A proxy class is present in java.lang package. A proxy class has certain methods which are used for creating dynamic proxy classes and instances, and all the classes created by those methods act as subclasses for this proxy class. Class declaration: public class Proxy extends Object implements Seria 4 min read java.lang.reflect.Modifier Class in Java The java.lang.reflect.Modifier class contains methods used to get information about class, member and method access modifiers. The modifiers are represented as int value with set bits at distinct positions. The int value represents different modifiers. These values are taken from the tables in secti 7 min read java.lang.reflect.Field Class in Java The ability of the software to analyze itself is known as Reflection. This is provided by the java.lang.reflect package and elements in Class .Field serves the same purpose as the whole reflection mechanism, analyze a software component and describe its capabilities dynamically, at run time rather t 5 min read java.lang.reflect.ReflectPermission Class in Java ReflectPermission class extends BasicPermission class. It is a ânamedâ permission i.e it contains a name but no action. It may implement actions on top of BasicPermission, if desired. It is used to get information about the behaviour of Constructors. ConstructorsDescriptionReflectPermission(String n 2 min read java.lang.MethodType Class in Java MethodType is a Class that belongs to java.lang package. This class consists of various types of methods that help in most of cases to find the method type based on the input object, or parameters of the method. All the instances of methodType are immutable. This means the objects of the methodType 4 min read java.lang.reflect.Constructor Class in Java java.lang.reflect.Constructor class is used to manage the constructor metadata like the name of the constructors, parameter types of constructors, and access modifiers of the constructors. We can inspect the constructors of classes and instantiate objects at runtime. The Constructor[] array will hav 4 min read Java.lang.Class class in Java | Set 1 Java provides a class with name Class in java.lang package. Instances of the class Class represent classes and interfaces in a running Java application. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. It 15+ min read Java.lang.Class class in Java | Set 2 Java.lang.Class class in Java | Set 1 More methods: 1. int getModifiers() : This method returns the Java language modifiers for this class or interface, encoded in an integer. The modifiers consist of the Java Virtual Machine's constants for public, protected, private, final, static, abstract and in 15+ min read Java.lang package in Java Java.lang package in JavaProvides classes that are fundamental to the design of the Java programming language. The most important classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time. Following are the Important Classes in Java.lan 3 min read Like