How to load a class programmatically?
Answer / madhu
public class MainClass {
public static void main(String[] args){
ClassLoader classLoader = MainClass.class.getClassLoader();
try {
Class aClass = classLoader.loadClass("com.tech.MyClass");
System.out.println("aClass.getName() = " + aClass.getName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
Is This Answer Correct ? | 5 Yes | 0 No |
explain how java se 8 data and time api solves issues of old java date api?
why i can not access private variable in other class?
Can a method be static and synchronized?
What is flatmap in rxjs?
What is an action class in java?
Are streams faster than for loops?
What is dependency injection in java?
What happens when the parent process of a child process exits before the child ?
What are the advantages of java sockets?
What is the means of java?
Why do we only use the main method to start a program?
What is the need to declare main() method as static in Java?