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

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

        Field sField = cls.getField("string1");
        System.out.println("Public field found: " + sField.toString());
    }
}

class MyClass {

    public MyClass() {
    }

    public MyClass(String string1) {
        this.string1 = string1;
    }

    public String string1 = "tutorialspoint";
}