Q:

Java program to get the list of methods of a class

belongs to collection: Java Class and Object Programs

0

Java program to get the list of methods of a class

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program/Source Code:

The source code to get the list of methods of a class is given below. The given program is compiled and executed successfully.

// Java program to get the list of methods 
// of a class

import java.lang.reflect.Method;

public class Main {
  public static void main(String[] args) throws ClassNotFoundException {
    Class cls = Class.forName("java.lang.Integer");

    Method methods[] = cls.getMethods();

    System.out.println("Methods of Integer class: ");
    for (Method method: methods)
      System.out.println(method);
  }
}

Output:

Methods of Integer class: 
public static int java.lang.Integer.numberOfLeadingZeros(int)
public static int java.lang.Integer.numberOfTrailingZeros(int)
public static int java.lang.Integer.bitCount(int)
public boolean java.lang.Integer.equals(java.lang.Object)
public static java.lang.String java.lang.Integer.toString(int)
public static java.lang.String java.lang.Integer.toString(int,int)
public java.lang.String java.lang.Integer.toString()
public static int java.lang.Integer.hashCode(int)
public int java.lang.Integer.hashCode()
public static int java.lang.Integer.min(int,int)
public static int java.lang.Integer.max(int,int)
public static int java.lang.Integer.reverseBytes(int)
public int java.lang.Integer.compareTo(java.lang.Object)
public int java.lang.Integer.compareTo(java.lang.Integer)
public byte java.lang.Integer.byteValue()
public short java.lang.Integer.shortValue()
public int java.lang.Integer.intValue()
public long java.lang.Integer.longValue()
public float java.lang.Integer.floatValue()
public double java.lang.Integer.doubleValue()
public static java.lang.Integer java.lang.Integer.valueOf(int)
public static java.lang.Integer java.lang.Integer.valueOf(java.lang.String,int) throws java.lang.NumberFormatException
public static java.lang.Integer java.lang.Integer.valueOf(java.lang.String) throws java.lang.NumberFormatException
public static java.lang.String java.lang.Integer.toHexString(int)
public static java.lang.Integer java.lang.Integer.decode(java.lang.String) throws java.lang.NumberFormatException
public static int java.lang.Integer.compare(int,int)
public static int java.lang.Integer.reverse(int)
public static long java.lang.Integer.toUnsignedLong(int)
public static int java.lang.Integer.parseInt(java.lang.String) throws java.lang.NumberFormatException
public static int java.lang.Integer.parseInt(java.lang.String,int) throws java.lang.NumberFormatException
public static int java.lang.Integer.parseInt(java.lang.CharSequence,int,int,int) throws java.lang.NumberFormatException
public static int java.lang.Integer.sum(int,int)
public static int java.lang.Integer.compareUnsigned(int,int)
public static java.lang.String java.lang.Integer.toUnsignedString(int,int)
public static java.lang.String java.lang.Integer.toUnsignedString(int)
public static java.lang.String java.lang.Integer.toOctalString(int)
public static java.lang.String java.lang.Integer.toBinaryString(int)
public static int java.lang.Integer.parseUnsignedInt(java.lang.String,int) throws java.lang.NumberFormatException
public static int java.lang.Integer.parseUnsignedInt(java.lang.CharSequence,int,int,int) throws java.lang.NumberFormatException
public static int java.lang.Integer.parseUnsignedInt(java.lang.String) throws java.lang.NumberFormatException
public static java.lang.Integer java.lang.Integer.getInteger(java.lang.String,java.lang.Integer)
public static java.lang.Integer java.lang.Integer.getInteger(java.lang.String,int)
public static java.lang.Integer java.lang.Integer.getInteger(java.lang.String)
public static int java.lang.Integer.divideUnsigned(int,int)
public static int java.lang.Integer.remainderUnsigned(int,int)
public static int java.lang.Integer.highestOneBit(int)
public static int java.lang.Integer.lowestOneBit(int)
public static int java.lang.Integer.rotateLeft(int,int)
public static int java.lang.Integer.rotateRight(int,int)
public static int java.lang.Integer.signum(int)
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public final void java.lang.Object.wait() throws java.lang.InterruptedException
public final native java.lang.Class java.lang.Object.getClass()
public final native void java.lang.Object.notify()
public final native void java.lang.Object.notifyAll()

Explanation:

In the above program, we created a public class Main that contains a main() method. The main() method is the entry point for the program.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java Class and Object Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
<< Java program to get the list of defined classes an...