java class forname newinstance deprecated code example Example: java newinstance alternative YourClass.getDeclaredConstructor().newInstance()