What is the easiest way to include both implicit and explicit casting to your code? It is a requirement for my Java project.
Graphic g = getGraphics();
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(5));
This is the only code I have. Is this considered implicit or explicit casting?
There are two cases to consider.
You can consider this implicit casting:
And this is an example of explicit casting. It is made explicit with the
(int).Hence, your example is explicit casting.