Created
June 24, 2021 02:02
-
-
Save pablohdzvizcarra/450b5d96f7289798658e95f61b2ffd3c to your computer and use it in GitHub Desktop.
example to how create manually a class with name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final String className = file.readUTF(); | |
final String personName = file.readUTF(); | |
final int age = file.readInt(); | |
final Class<?> personClass = Class.forName(className); | |
final Constructor<?> constructor = | |
personClass.getConstructor(String.class, int.class); | |
return (Person) constructor.newInstance(personName, age); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment