title: Java: Using printf() to BOTH left justify and right justify on SAME line
body: <p>In Java, how could I use printf() to <strong>both</strong> left justify and right justify output on the <strong>same</strong> line consistently?
  This is the code for <em>everything</em> left justified:</p>
  
  <pre><code>System.out.println("   ********************L********R");
  String[] array = {"apple", "pie", "cheese"};
  double[] array2 = {0.003, 1245, 19.979};
  double[] array3 = {0.2, 1, 9};
  for (int index = 0; index &lt; array.length; index++)
  {
      System.out.printf("   %-10s%-10.2f%.2f%n", array[index], array2[index], array3[index]);
  }
  </code></pre>
  
  <p>This is the output that <em>everything</em> is left justified:</p>
  
  <pre><code>   ********************L********R
     apple     0.00      0.20
     pie       1245.00   1.00
     cheese    19.98     9.00
  </code></pre>
  
  <p>What I want instead if that for the third elements (0.20, 1.00, 9.00) to be <strong>right</strong> justified. I indicated in the output above that "L" is left justified, but I want the variables to be right justified where the "R" is. How can I right justify the output on the right (0.20, 1.00, 9.00), while also keeping the output on the left (apple, pie, cheese) left justified?</p>