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 |
What is difference between loosely coupled and tightly coupled in java?
What do you understand by numeric promotion?
What is a controller in java?
how ahstraction is the property of oops,this is also in c and c++ ex. printf function which is also hide the unnecessary data,so what is the difference ? and does c++ fallow the abstraction?
What's the difference between code-based security and role-based security? Which one is better? : java security
What is the meaning of loosely coupled in java?
What is microservices java?
What is the difference between map and flatmap in java?
Is jvm a compiler or an interpreter?
How do I open the java console in windows 10?
What if I do not provide the string array as the argument to the method?
What is a yaml file in java?