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) {

        MyClass cls = new MyClass();
        Class c = cls.getClass();

        // returns the array of Method objects
        Method[] m = c.getDeclaredMethods();
        for (int i = 0; i < m.length; i++) {
            System.out.println("method = " + m[i].toString());
        }
    }
}

class MyClass {

    public MyClass() {
        // no argument constructor
    }

    public void showString(String string1) {
        this.string1 = string1;
    }

    private void showInteger(Integer i) {
        this.i = i;
    }

    public Integer i = 10;
    private String string1 = "tutorialspoint";
}