Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.reflect.Field;

public class Main {

    public static void main(String[] args) {

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

            // returns the array of Field objects
            Field[] fields = cls.getDeclaredFields();
            for (int i = 0; i < fields.length; i++) {
                System.out.println("Field = " + fields[i].toString());
            }
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}

class MyClass {
    public MyClass() {
        // no argument constructor
    }

    public MyClass(long l, int i) {
        this.l = l;
        this.i = i;
    }

    long l = 77688;
    int i = 3;
}