title: How to display a variable's value in a message box?
body: <p>I want to display the "number of names". Suppose if I enter two name, it should display ""you have entered 2 names.</p>
  
  <p>import javax.swing.JOptionPane;</p>
  
  <pre><code>public class MyName {
  public static void main (String args [ ])
  
  {
      int option;
      String userName;
  
      do
      {
          option = JOptionPane.showConfirmDialog(null,"Want to enter another Name?");
  
      } while (option == JOptionPane.YES_OPTION);
  
      JOptionPane.showMessageDialog(null, "you have entered" + (number of names) + "names");
  
  }
  }
  </code></pre>