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();

            Field lVal = cls.getDeclaredField("l");
            System.out.println("Field = " + lVal.toString());
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}

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

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

    long l = 123L;
}