title: How to display asterisk for input in Java?
body: <p>I need to write a little program in Java that asks a person to enter a Pin Code.
  So I need the Pin to be hidden with asterisks (*) instead of the numbers. How can I do that?</p>
  
  <p>So far, this is my code :</p>
  
  <pre><code>import java.util.Scanner;
  import java.io.*;
  
  
  public class codePin {
  
      public static void main(String[] args){
  
          int pinSize = 0;
  
          do{
              Scanner pin = new Scanner(System.in);
              System.out.println("Enter Pin: ");
              int str = pin.nextInt();
              String s = new Integer(str).toString();
  
              pinSize = s.length();
  
              if(pinSize != 4){
              System.out.println("Your pin must be 4 integers");
              } else {
              System.out.println("We're checking if Pin was right...");
              }
  
          }while(pinSize != 4);
      }
  }
  </code></pre>
  
  <p>Actually this program works for now, but I want to add a functionality to display Pin like "* * * <em>" or "</em> * *" etc... (in the console when the Person enters is own Pin).
  I found something to entirely hide the Pin, but I do not want this. I want the Pin with asterisks</p>
  
  <p>Any ideas ? Thanks</p>