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