title: How to print multiple variable lines in Java
body: <p>I'm trying to print the test data used in webdriver test inside a print line in Java</p>
  
  <p>I need to print multiple variables used in a class inside a <code>system.out.print</code> function (<code>printf</code>/<code>println</code>/whatever).  </p>
  
  <pre><code>public String firstname;
  public String lastname;
  
  firstname = "First " + genData.generateRandomAlphaNumeric(10);
  driver.findElement(By.id("firstname")).sendKeys(firstname);
  
  lastname = "Last " + genData.generateRandomAlphaNumeric(10);
  driver.findElement(By.id("lastname")).sendKeys(lastname);
  </code></pre>
  
  <p>I need those print in a print statement as:<br>
  First name: <em>(the variable value I used)</em><br>
  Last name: <em>(the variable value I used)</em></p>
  
  <p>Using something like below gives the exact result.<br>
  But I need to reduce the number of <code>printf</code> lines and use a more efficient way.</p>
  
  <pre><code>System.out.printf("First Name: ", firstname);
  System.out.printf("Last Name: ", lastname);
  </code></pre>
  
  <p>Thanks!</p>