dimanche 2 octobre 2016

Whats the difference between MyObject.class.newInstance() and new MyObject()? [duplicate]

This question already has an answer here:

I have this class:

public final class MyObject{
}

Whats the difference between calling:

  1. new MyObject();
  2. MyObject.class.newInstance();

And does #2 use reflection?

Note: I have seen similar posts, but they all used Class.forName("...").newInstance() which is a whole other story.





Aucun commentaire:

Enregistrer un commentaire