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