MyClass.class.getDeclaredConstructor(String.class).newInstance("HERESMYARG");
or
obj.getClass().getDeclaredConstructor(String.class).newInstance("HERESMYARG");
More Related Contents:
- Constructors giving me an headache Java
- Why i can’t initialize variable in parent class’ constructor? [closed]
- Java error when I try to create an object with a constructor with a string parameter [closed]
- Java default constructor
- Why are my fields initialized to null or to the default value of zero when I’ve declared and initialized them in my class’ constructor?
- Are fields initialized before constructor code is run in Java?
- Constructor overloading in Java – best practice
- Methods vs Constructors in Java
- Leaking this in constructor warning
- Why is Class.newInstance() “evil”?
- Is it good practice to make the constructor throw an exception? [duplicate]
- In what order do static blocks and initialization blocks execute when using inheritance?
- Deep copy of an object array
- Is it OK to call abstract method from constructor in Java? [duplicate]
- State of Derived class object when Base class constructor calls overridden method in Java
- Why can’t Java constructors be synchronized?
- Java: newInstance of class that has no default constructor
- constructor of subclass in Java
- How to get the parameter names of an object’s constructors (reflection)? [duplicate]
- using a variable in constructor in a method outside of constructor
- How many objects are created due to inheritance in java?
- Java Lombok: Omitting one field in @AllArgsConstructor?
- Protected constructor and accessibility
- JPQL: Receiving a Collection in a Constructor Expression
- Cannot instantiate the type for class object (Java)
- How can I access a private constructor of a class?
- Is it possible in java to create ‘blank’ instance of class without no-arg constructor using reflection?
- What is the purpose of a no-arg constructor?
- In Scala, how can I subclass a Java class with multiple constructors?
- Why can’t I refer to an instance method while explicitly invoking a constructor?