title: Java never declares access level of variables in methods whether static or not
body: <p>Today I suddenly realized that Java never specifies access level for local variables when I try to declare a variable for main method. I also tried to give it a access level modifier, but it doesn't compile. The error is:
  <strong>Illegal modifier for parameter t1; only final is permitted</strong></p>
  
  <pre><code>package myThread;
  
  import java.lang.Thread;
  import java.lang.String;
  import java.lang.System;
  
  public class PrintThread extends Thread{ //extends Thread class
  
      private long sleepTime;
  
      public PrintThread(String name)
      {
          super(name);
          this.sleepTime = (long) (java.lang.Math.random() * 5000);
  
          System.out.println("Thread: " + getName() + ", sleepTime: " + sleepTime);
      }
  
      public void run() // override run method
      {
          System.out.println(getName() + " go to sleep...");
          try
          {
              sleep(sleepTime);
          } catch (InterruptedException e)
          {
              e.getMessage();
          }
          System.out.println(getName() + " out of sleep!");
      }
  
      public static void main(String[] args)
      {
          public PrintThread t1 = new PrintThread("T1"); // CANNOT COMPILE
          t1.start(); // start thread by start() method
      }
  }
  </code></pre>
  
  <p>As we know, we need to use <strong>public protected package private static final</strong> etc to specify a member variable of java class.</p>
  
  <p>But we never do this for class method (static or not) variable.</p>
  
  <p>I was stuck with this conception all day. Previously, I just write java code as usual but didn't realize this phenomenon.</p>
  
  <p>Could you give me hints. I CANNOT persuade myself just by eliminate <strong>public</strong> keyword for t1.</p>