hi how I have a question that is killing me I hope you can help me
what I know according to what I understand:
You can not instantiate objects of an abstract class
my doubt:
The Graphics2D class inherits from Graphics both are abstract so I can not instantiate objects directly from both. then I created a GraFi class that extends or inherits Graphics and then I want to cast it to Graphics2D but I have an error
error:
Cannot cast from GraFi to Graphics2D
I thought maybe it's because Graphics2D can not be transformed by the level of inheritance (maybe I'm wrong).
Now when I do this things change but I would like to know why:
As you can see there, the error disappears, but there is a doubt if, when creating an object of the GraFi class that I inherited from Graphics, it would not let me convert it to Graphics2D because now that I install a Grafi object to graphics Graphics belonging to Graphics and I do not get an error if in both cases you are trying to convert graphics to Graphics2D even if in the first case you think so
Grafi graficoDeGraphics = new Grafi();
if GraFi has belonged to GraFi