How to validate phone number(US format) in Java?
<p>I just want to know where am i wrong here:    </p>

<pre><code>import java.io.*;


    class Tokens{   
            public static void main(String[] args)
            {
               //String[] result = "this is a test".split("");

                String[] result = "4543 6546 6556".split("");
                boolean flag= true;         

                String num[] = {"0","1","2","3","4","5","6","7","8","9"};
                String specialChars[] = {"-","@","#","*"," "};


                for (int x=1; x&lt;result.length; x++)
                {   
                    for (int y=0; y&lt;num.length; y++)
                    {
                        if ((result[x].equals(num[y])))
                        {
                            flag = false;
                            continue;

                        }
                        else
                        {
                            flag = true;
                        }


                        if (flag == true)
                        break;

                    }   

                if (flag == false)
                break;

                }           

                System.out.println(flag);

            }

    }
</code></pre>
