title: Can I pass an array as arguments to a method with variable arguments in Java?
body: <p>I'd like to be able to create a function like:</p>
  
  <pre><code>class A {
    private String extraVar;
    public String myFormat(String format, Object ... args){
      return String.format(format, extraVar, args);
    }
  }
  </code></pre>
  
  <p>The problem here is that <code>args</code> is treated as <code>Object[]</code> in the method <code>myFormat</code>, and thus is a single argument to <code>String.format</code>, while I'd like every single <code>Object</code> in <code>args</code> to be passed as a new argument. Since <code>String.format</code> is also a method with variable arguments, this should be possible.</p>
  
  <p>If this is not possible, is there a method like <code>String.format(String format, Object[] args)</code>? In that case I could prepend <code>extraVar</code> to <code>args</code> using a new array and pass it to that method.</p>