title: Difference between Graphics and Graphics2D?
body: <p>What is difference between <strong>Graphics</strong> and <strong>Graphics2D</strong>?<br>
  Whether  Graphics2D is extend of Graphics? </p>
  
  <pre><code>public void paintComponent(Graphics g)
  {
      super.paintComponent(g);
      g.drawRect(25, 25, 20, 20); //use Graphics to paint rectangle
      Graphics2D g2 =(Graphics2D)g;
      g2.drawRect(0, 0, 20, 20); // use Graphics2D to paint rectangle
  }
  </code></pre>