I thought that .class was the class of the object it was being called on. However this does not fit with what I was trying to do with a program. I'll give some examples.
//o is of type Object
//this method throws error "cannot find symbol" for the cast method
SampleClass.cast(o);
//sampleClass is an instance of SampleClass
//this method throws error "<identifier> expected"
sampleClass.class.cast(o);
//this method works!
SampleClass.class.cast(o);
//this returns two "<identifier> expected" errors
sampleClass.class.class.cast(o);
//this works too!
((SampleClass) o)
I previously thought that sampleClass.class == SampleClass, an object of type Class. I also thought that SampleClass.class would return something really meta that's hard to think about. Now I know that I don't really know anything. Any help solving this conundrum is appreciated :)
Edit: Thanks everyone! I'm happy to be learning this about Java. I'm grateful for the help