how to print String in the queue basic loop
<p>I want to create a method that runs all of jobs in a queue(a Job list). I have created a method to run one job(<code>runAJob</code>), and below method is to run all of jobs in the queue list, until the time(myTimeLeft)runs out.<br>
now, this code always leaves 1 ArraLyist when I run  <code>runAll</code> method. Would anyone tell me why it is wrong?  </p>

<pre><code>   /**
  * Run the first job on the queue if there is enough time on the clock and the job queue list is not empty.
  * And move the job to the finished jobs list.
  */
public void runAJob(){
   myJobDuration = myJobInQueue.get(0).getDuration();
   if(!myJobInQueue.isEmpty())
   {
        if (myJobDuration &lt; myTimeLeft)
        {
            myTimeLeft = myTimeLeft - myJobDuration;
            myFinishedJobs.add(myJobInQueue.get(0));
            System.out.println("A job is running: " + myJobInQueue.get(0).getName());
            myJobInQueue.remove(0);
        }
        else 
        {
            System.out.println("Not enogth running time left, please add time on the clock.");             
        }
   }
   else 
   {
     System.out.println("No pending job on the list.");
   }
}

/**
  * Run all the jobs on the queue in order until it runs out of time.
  */  
public void runAll()
{
  int counAJob =0; 
  while (myJobDuration &lt; myTimeLeft &amp;&amp; !myJobInQueue.isEmpty()) {
   // get next item from queue
     runAJob();
     System.out.println("A job is running: ");
  }

}
</code></pre>
