|
Relates :
|
|
|
Relates :
|
Example 4.3.1-1. Object Creation contains the code
try {
p = (Point)Class.forName("Point").newInstance();
} catch (Exception e) {
System.out.println(e);
}
Class.newInstance was deprecated by JDK-6850612 in JDK 9 since it can throw undeclared checked exceptions. The recommended replacement code is:
try {
p = (Point)Class.forName("Point").getDeclaredConstructor().newInstance();
} catch (ReflectiveOperationException e) {
System.out.println(e);
}