Read every word on this link to the scanner class and your current question, and many future questions you would have had, will be answered.