Why and when we can instantiate a class directly
Human human1 = new Human("john", "doe");
and why and when we retrieve a reference to an instance already done ?
Context.getSystemService(Context.TELEPHONY_SERVICE).
Why and when we can instantiate a class directly
Human human1 = new Human("john", "doe");
and why and when we retrieve a reference to an instance already done ?
Context.getSystemService(Context.TELEPHONY_SERVICE).
Every time you call the class constructor you create a new instance of the class. in your example you can have several Human instances for "John Doe" that exist independently of each other.
With Context.getSystemService(...)
you get a reference to a singelton. Every android app will comunicate with the same TELEPHONY_SERVICE instance.
You can only retrieve a reference to a class A: when you know it has been instantiated itself and B: when you have the proper access to get the reference you want. The reason you would do this is because there is some work you want to do on this instance that is already created, and you want this work to be available to future uses of this instance for example changing John Doe's last name.
On the other hand, you can always choose to instantiate a new object, but it is not always useful. For example there is no reason to do the following:
Human human1 = new Human("John", "Doe");
human1 = SomeHumanThatAlreadyExists;
The first line is useless, and this John, Doe, object will eventually be garbage collected without being used. This is a basic answer to a basic question, if you would like a more advanced answer, ask a more specific question.