Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by NavBot

...

Code Block
bgColor#FFcccc
public class Scope {
  public static void main(String[] args) {
    int i = 0;
    for(i = 0; i &lt;< 10; i++) {
      // Do operations
    }
  }
}

...

Code Block
bgColor#ccccff
public class Scope {
  public static void main(String[] args) {
    for(int i = 0; i &lt;< 10; i++) { //contains declaration
      // Do operations
    }
  }
}

...

Wiki Markup
\[[JLS 05|AA. Java References#JLS 05]\] [Section 14.4.2, Scope of Local Variable Declarations|http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.4.2]
\[[Bloch 01|AA. Java References#Bloch 01]\] Item 29, Minimize the scope of local variables

...

05. Scope (SCP)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      05. Scope (SCP)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      SCP01-J. Do not increase the accessibility of overridden or hidden methods