title: How can we pass variables from one method to another in the same class without taking the help of parent class?
body: <p>let's take a simple program like this :</p>
  
  <pre><code>public class Dope
  {
  public void a()
  {
     String t = "my";
    int k = 6;
  }
  public void b()
  {
      System.out.println(t+" "+k);/*here it shows an error of not recognizing any variable*/
  }
  public static void main(String Ss[])
   {
  
   }   
  }
  </code></pre>
  
  <p>although i can correct it by just resorting to this way :</p>
  
  <pre><code>  public class Dope
  {
  String t;
    int k ;
  public void a()
  {
      t = "my";
     k = 6;
  }
  public void b()
  {
      System.out.println(t+" "+k);
  }
   public static void main(String Ss[])
   {
  
   }   
  }
  </code></pre>
  
  <p>but i wanted to know if there's any way in my former program to pass the variables declared in <code>method a</code> to <code>method b</code> without taking the help of parent class ?</p>