Home Java Reflect Getting the method name used in the Application



Getting the method name used in the Application
Posted on: February 28, 2008 at 12:00 AM
In this section we describe how to retrieve method name by using the getMethods() method. Here is an example that demonstrates the use of the getMethods() method in more detail.

Getting the method name used in the Application

     

In this section we describe how to retrieve method name by using the getMethods() method. Here is an example that demonstrates the use of the getMethods() method in more detail.

Define a class named "Fmethod" and then create an object of this class and get the reference of java.util.Integer.class into it. Now retrieve the method name by using the getMethods() method.

Here is the code of the Example :

Fmethod.java:  

import java.lang.reflect.*;

public class Fmethod{
  public static void main(String[] args){
  Class cls = java.lang.Integer.class;
  Method method = cls.getMethods()[0];
  String info;
  info = method.getName()
  System.out.println(info);
  }
}

Here is the output of the Example :

C:\roseindia>javac Fmethod.java

C:\
roseindia>java Fmethod
hashCode

Download this Example:

Related Tags for Getting the method name used in the Application:
javacclassreferenceobjectiomethodsintegermethodgetnameusingintthisaicreatedefineieexampletotailexamrefeilitdessectiondemousetrieceinnoasmnttrjclesretrieveemnamedmehowintoobjrateratesdetaildetaildescribereferxaxampsatishampleaandstrutilvautiscrssrirenthavsthatfefingetmethodjepleplndodsono


More Tutorials from this section

Ask Questions?    Discuss: Getting the method name used in the Application  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.