import java.lang.reflect.Method;

/**
 * Project: Hello World Variations
 * Author: Molla Samser
 * Company: RSK World
 * Website: https://rskworld.in
 * Contact: +91 93305 39277
 * Support: help@rskworld.in
 * Year: 2026
 * 
 * Description: Using Java Reflection to call a method by its name.
 */

public class ReflectionHelloWorld {
    public void sayHello() {
        System.out.println("Reflection: Hello World from RSK World!");
    }

    public static void main(String[] args) {
        try {
            // Get class instance
            ReflectionHelloWorld obj = new ReflectionHelloWorld();
            Class<?> clazz = obj.getClass();

            // Get method by name and invoke it
            Method method = clazz.getDeclaredMethod("sayHello");
            method.invoke(obj);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
