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 reflection in java?
What is persistence xml in java?
Explain the Sequence Diagram?
What is meant by framework in java?
How do I run a java project in netbeans?
What is transactional in java?
What is lambda used for?
What happens when you omit a brace or misspell one of the words, like public or
What is the difference between Enumeration and Iteration interfaces? What is the way of to retreive the objects from these interfaces ?
Which version of jdk is required for netbeans 8.0 2?
Who created eclipse?
What is the content reside in Use case Document?