title: Is it good to declare a local variable in the middle level of your code?
body: <p>while reading the book "clean code" I came across the following instruction:</p>
  
  <p>"Local variables
  should be declared just above their first usage and should have a small vertical scope. We
  don’t want local variables declared hundreds of lines distant from their usages."</p>
  
  <p>see the following example:</p>
  
  <pre><code> public class A {
  
      public static void main(String[] args)  {
  
          String name = "Robert";
          String country = "iiiii";
          int age = 21;
          String hobby = "Soccer";
          System.out.println("my name is "+name+"I'm "+age+" and I'm from "+country);
          /*
  
               * 
               * a lot of code here
               * 
               * */
              System.out.println("my hobby is: " + hobby);
  
          }
      }
  </code></pre>
  
  <p>Here the variable hobby is a throw stone from its usage , so I want to make sure if it is clean to write like the code bellow?, because I often see local variables declared in the top level of the function : </p>
  
  <pre><code>/*the previous code here*/
  String hobby = "Soccer";
  System.out.println("my hobby is: " + hobby);
  </code></pre>