Skip to content

Instantly share code, notes, and snippets.

@pablohdzvizcarra
Created June 24, 2021 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pablohdzvizcarra/450b5d96f7289798658e95f61b2ffd3c to your computer and use it in GitHub Desktop.
Save pablohdzvizcarra/450b5d96f7289798658e95f61b2ffd3c to your computer and use it in GitHub Desktop.
example to how create manually a class with name
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