Java condition Statement, HELP??

Programming
Tutor: None Selected Time limit: 1 Day

How do you write a simple condition statement in java, that gives an error message if a user input a character or a string instead of an integer only

Apr 13th, 2015

check this code....

public class Test {

    public static void main(String[] args) {

       Scanner input = new Scanner(System.in);

       

       if(input.hasNextInt()){

           System.out.println("It is a integer number");

       }

       else {

          System.out.println("Please Enter Integer"); 

       }

    }

   

}


Apr 14th, 2015

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Apr 13th, 2015
...
Apr 13th, 2015
Dec 9th, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer