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 |
Is jdk a compiler?
What is @qualifier in java?
When do we go for java 8 stream api? Why do we need to use java 8 stream api in our projects?
Topic- looping,function overloading,nesting ,polymorphism. Aim - to write a function with a name buzz-buds,that will check whether the given numbers are buddies or not on the basis of no. of parameters passed during function calling.
Which class is the superclass of every class?
What are struts java?
What is transactional in java?
Why are command line arguments passed as a string?
Do I really have to type in the programs in the book to try them out?
Do I need jdk or jre?
What is java ioc?
What is tuple2?