Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Java
Expertise: Advanced
May 14, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Determine the Characteristics of a Java Method

The java.lang.reflect defines a Method class that may be used to get information about a method in a Java class. Some of the main methods are:
public native int getModifiers(); // e.g. public, private, static
public Class getReturnType(); // primitive or object type
public Class getDeclaringClass (); // class that declares this Method
public String getName(); // string name of the method
public Class[] getParameterTypes(); // parameter types passed in
public Class[] getExceptionTypes(); // exception types thrown

// Invoke this Method
public native Object invoke(Object o, Object[] args)
   throws IllegalAccessException, IllegalArgumentException,              

The first six methods listed here can provide all the details to determine the characteristics of a Java method. You can use these methods to obtain each of the elements that go in a method declaration. For example, a typical Java method will have this syntax:
[modifiers] <return_type> <name> (paramType1 param1, paramType2, param2, 
Ajit Sagar
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date