graphics « cast « Java Data Type Q&A





1. What is the most elegant way to cast a variable you just received as an argument?    stackoverflow.com

More specifically, what's the most elegant way to cast the Graphics object in a paint() call up to a Graphics2D object?

public void paint(Graphics g) {
    // How do ...