title: How to pass an object to a constructor?
body: <p>I have this code</p>
  
  <pre><code>import javax.swing.*
  import java.util.TimerTask;
  public class myClass extends TimerTask{
  
      JSlider j;        
  
      // constructor
      public myClass (JSlider j) {
      this.j = j;
          ... do stuff e.g. use "j"...
      }
  }
  </code></pre>
  
  <p>How do I now call <em>myClass</em> and pass it a JSlider value?</p>
  
  <pre><code>JSlider slider0;
  new MyClass(slider0);
  </code></pre>
  
  <p>Is all of the above the appropiate way to do it? </p>