Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.reflect.Method;

public class Main {

    public static void main(String[] args) {

        Class cls = String.class;

        Method[] m = cls.getMethods();
        for (int i = 0; i < m.length; i++) {
            // returns te declaring class
            Class dec = m[i].getDeclaringClass();
            // displays all methods
            System.out.println("Method = " + m[i].toString());
            System.out.println(" Declaring class: " + dec.toString());
        }
    }
}