Java condition Statement, HELP??

label Programming
account_circle Unassigned
schedule 1 Day
account_balance_wallet $5

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

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Apr 13th, 2015
...
Apr 13th, 2015
Jun 26th, 2017
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