title: Show me how `String n = null;` works?
body: <p>This is my code, and it works exactly how I want it to, but I picked up using</p>
  
  <p><code>String n = null;</code></p>
  
  <p>when dealing with switch statements, can someone explain to me why it works the way it does in this code so that I can better understand this concept?</p>
  
  <pre class="lang-java prettyprint-override"><code>//Tells a user what number corresponds with what numbers on a telephone
  
  import java.util.Scanner;
  
  public class KeyPad 
  {
     public static void main (String [] args) 
     {
     //Initialize Scanner
     Scanner input = new Scanner(System.in);
  
     //Variables
     String x;
     char c;
  
     //Input
     System.out.println("Enter a letter: ");
     x = input.next();
  
     //Convert to lowercase
     x = x.toLowerCase();
     c = x.charAt(0);
  
     //Assign reference variable 
     String n = null;
  
     //Switch conditions
     switch (c)
        {   
        case 'a':
        case 'b':
        case 'c': n = "2";
           break;
        case 'd':
        case 'e':
        case 'f': n = "3";
           break;
        case 'g':
        case 'h':
        case 'i': n = "4";
           break;
        case 'j':
        case 'k':
        case 'l': n = "5";
           break;
        case 'm':
        case 'n':
        case 'o': n = "6";
           break;
        case 'p':
        case 'q':
        case 'r':
        case 's': n = "7";
           break;
        case 't':
        case 'u':
        case 'v': n = "8";
           break;
        case 'w':
        case 'x':
        case 'y':
        case 'z': n = "9";
           break;                                 
        }       
     //Output
     System.out.println("The corresponding number is " + n);    
     }
  }
  </code></pre>