title: How to ignore special characters and spaces in string?
body: <p>So i developed this code to convert a word to phone numbers and how do i code it to ignore the spaces entered while displaying the result?</p>
  
  <p>So what i meant is to allow the user to entered spaces between the words but is not reflected in the result.</p>
  
  <pre><code> import java.util.Scanner;
  
  {
  public static void main (String[] args)
  {
  Scanner  console = new Scanner(System.in);
  
  
  {  
  System.out.println("Enter the a word to be converted : ");
  
  String  Letter = console.next ();
  Letter = Letter.toUpperCase();
  Letter = Letter.toLowerCase();
  String  Number="";
  
  int count=0;
  int  i=0;
  
  while(count &lt; Letter.length())
    {switch(Letter.charAt(i))
     {case 'A':case 'B':case 'C': case 'a': case 'b': case 'c':
                Number += "2";
                count++;
        break;
    case 'D':case 'E':case 'F': case 'd': case 'e': case 'f':
                 Number += "3";
                count++;
        break;
     case 'G':case 'H':case 'I': case 'g': case 'h': case 'i':
                Number += "4";
                count++;
        break;
      case 'J':case 'K':case 'L': case 'j': case 'k': case 'l':
  
                Number += "5";
               count++;
        break;
      case 'M':case 'N':case 'O': case 'm': case 'n': case 'o':
            Number += "6";
                count++;
        break; 
      case 'P':case 'R':case 'S': case 'p': case 'r': case 's':
                Number += "7";
                count++;
        break;
      case 'T':case 'U':case 'V': case 't': case 'u': case 'v': 
              Number += "8";   
              count++;
        break;
      case 'W':case 'X':case 'Y':case 'Z': case 'w': case 'x': case 'y': case 'z':
           Number += "9";
           count++;
        break;
        }
      if(  count==3) {
         Number += "-";
     }
     i++;
             }     
      System.out.println( Number );
  
     }
  
  
     }}
  </code></pre>