Since class object is the entry point for reflection let's not see how we can access a class object 2
. 3
There are three ways to access a class object. 4
And here are those interests. 5
First one is via an object reference. 6
That is your code has access to an object reference and you can get the corresponding class object by 7
invoking the get class method on the object reference get class as a final method in the Object class 8
. 9
And it was briefly mentioned when we covered object class. 10
Second we is to invoke the topic from the method in the class. 11
Class itself turns to something called class and it grows. 12
Let's not look at each of these matters. 13
Two examples hit up a couple of examples when using object reference in the first example. 14
Get classes in honest cringle occur. 15
And that would read a class object corresponding boost Krink class in the second example we instantiating 16
hash set which is a class in Java that Udal package the reference type set is an interface and Javadoc 17
util package and is implemented bajas said. 18
No be involved get class on the object reference we get a class object for Hassid class or not for the 19
certain duffus. 20
OK so just keep that in mind. 21
Just not a variable named class which ends with Susy's. 22
That's just a convention that many don't have much use for variables referencing a class object. 23
You cannot of course use the named class with suffix s as it is a reserved keyword. 24
No let's look at the second approach which is to use topical Fortnum method from the class class input 25
to this method must be a fully qualified name of the class. 26
Next it cannot be used on primitives if you recall every primitive also has a class object but it's 27
just that we cannot get the class object using this particular approach. 28
We can get it to the third approach. 29
Now here are a few examples. 30
The first example is straightforward. 31
We're fully qualified name or string classes used second third and fourth. 32
Examples are related to address. 33
Second example returns a class object corresponding to an army of primitive type double syngas good 34
record indicates a one dimensional array and characters be represented primitive type double. 35
If we close two dimensional array there would have been squared brackets like in the last example. 36
So with each added dimension an additional square brackets would be inserted. 37
Third example is related to an array of some objects where the object is. 38
In this case for an object the syntax invokes the last name preceded by the character L and adding with 39
the semicolon and the semi-colon in the end is required and hence is emphasized in red. 40
Last example returns as class object corresponding to two dimensional array of type string. 41
Next let's look at the third approach. 42
What accessing a class object by appending dot goes to the right name. 43
We can also get X class object equites with classes interfaces arrays. 44
But it was too sick and did not work with primitives. 45
So you would have used this approach for primitives. 46
Now here are a few examples just wandered into a class object for string. 47
Second need a class object for primitive boolean. 48
Third one Regents class object corresponding good three dimensional array of type and find an example 49
returns a class object for the White keyword reconquered a class object can also be created. 50
Why you would have a demo where we can see how a class object of white keyword can be useful. 51
Here are some additional legal support for name and class literal approaches. 52
These points highlight their differences to first one is about whether or not compiler checks if the 53
corresponding class file exists on disk. 54
Compiler does not do any such checks for the form name approach. 55
The check is put on directly a runtime class not one exception will be raised if the class is not home 56
. 57
However for class literal approach compiler checks whether or not the class exists on disk if only source 58
code exists but not the class when the compiler automatically compiles the source code and so compiler 59
ensures that the class file is dead on disk not at runtime. 60
If somehow the dot class one is not found then JVM throws an error code. 61
No class Duffin error which implies that the class definition existed during compilation time but not 62
anymore. 63
Second point is about initialization which is a third stage of the lifetime of type. 64
With regards to Farnam approach. 65
Class gets loaded and also initialized but for class Necros only classes are ordered and initialization 66
happens or even is documented. 67
Or a static field that is not at compile time constant is access for the very first time. 68
So that's like a lazy initialization for the classical approach. 69
We already know the third point of it first name. 70
We can order class objects for primitives which would be possible with glossily crowds. 71
Finally there is this field called Type in every box but Amaka. 72
If you recall baulks primitive is a proper class for a primitive accessing pipe in a box. 73
Perimeter guilded in the class object for the corresponding perimeter. 74
Similarly a box would never do. 75
There is a class called White and Gelug outlying package. 76
This class also has pipefitter which will return the class object for the White keyword. 77
Note that word class is non-instructional as it has a private constructor. 78
So other than using a class literal you can also use a type who used to create a class object for primitives 79
unboiled and general use in dog class seems to be preferrable using the pipe. 80
So that support accessing class object. 81
Next let's do them all gave me explore reflection