Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Color;
import java.lang.reflect.Field;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getColor("blue"));
    }

    public static Color getColor(String colorName) {
        try {
            Field field = Class.forName("java.awt.Color").getField(colorName);
            return (Color) field.get(null);
        } catch (Exception e) {
            return null;
        }
    }
}