title: Local variable is allowed the same name as global variable?
body: <p>I am aware in certain circumstances you can have a global variable and a local variable which have the same name such as</p>
  
  <pre><code>int i = 0;
  
  public Something(int i) {
      this.i = i;
  }
  </code></pre>
  
  <p>However I am confused to why this works. My code looks a little like this</p>
  
  <pre><code>TableRowSorter dataSorter; //Global Variable
  
  public void setUpTable() {
      //Some Code
      dataSorter = new TableRowSorter(table.getModel());
      table.setRowSorter(dataSorter);
      DefaultRowSorter dataSorter = (DefaultRowSorter) table.getRowSorter(); //Local Variable
      //Some More Code
  }
  </code></pre>
  
  <p>Why is the <code>DefaultRowSorter</code> allowed to have the same variable name as <code>TableRowSorter</code> does?</p>