All things are objects
Class is an object of Java.lang.Class
Package Com.mysec.reflex;
Import Java.util.Scanner;
Any class is an instance object of class
public class Officebeffer {
public static void Main (string[] args) {
Scanner sc = new Scanner (system.in);
String name = Sc.nextline ();
Methodstart (name);
}
public static void Methodstart (String name) {
try {
Know that objects of this class pass the GetClass method
Test C1 = new test ();
C1.getclass ();
Any class has an implied static member variable
class<?> C2 = Test.class;
Dynamically loading classes, loading at run time
Com.mysec.reflex.Word
class<?> C = class.forname (name);
//Create objects of this class by class type
officeable OA = (officeable) c.newinstance ();
Oa.start ();
} catch (Exception e) {
E.printstacktrace ();
}
}
}
Package Com.mysec.reflex;
Public interface Officeable {
public void start ();
}
Package Com.mysec.reflex;
public class Word implements officeable{
@Override
public void Start () {
System.out.println ("Wordstarts ...");
}
}
Dynamic class loading for Java classes