I don\'t really understand how the class
keywords work in some instances.
For example, the get(ClientResponse.class)
method takes the Cl
The Class
class, which is different from the class
keyword, is meta-data describing instances. It tells you about the methods, data members, constructors, and other features of the instances that you create by calling new
.
For example get(ClientResponse.class) method takes the ClientResponse.class how does it uses this when it gets it and what are the advantage over just passing a instance of it?
You can't pass an instance of ClientResponse
to this method; it's expecting meta-data about all instances of ClientResponse
. If you passed an instance, you'd expect that the method might change the state of that instance. But passing the meta-data about all instances might allow the method to create a new kind of instance (e.g. a dynamic proxy) or do something else that depends on the meta-data about all instances of ClientResponse
. See the difference?