Here we are describing the use of using Argument exception in java .Exceptions are the way in Java to indicate to a calling method that an abnormal condition has occurred.
Here we are describing the use of using Argument exception in java .Exceptions are the way in Java to indicate to a calling method that an abnormal condition has occurred.In this Tutorial we explain an example from Argument exception in java .Exceptions are the condition in Java to indicate a calling method that an abnormal condition has occurred. This tutorial describes how to handle Argument exceptions appropriately in your programs. The steps involved in the program are described below:-
private static Scanner key = new Scanner(System.in):-Here we are declaring Scanner class object. Scanner is a class which is used to parse primitive types and strings using regular expressions.
Input = key. next():-This is the method by which we can find and returns the next complete token from this scanner.
System.out.println(Input + " is not an Integer value" + "\n"+ "Please enter appropriate value"):-This is the Exception message which is to be displayed if the number you entered is not a real number.
ArgumentException.java
|
Output of the program
Please enter a real number : Girish Girish is not an Integer value Please enter apporipriate value |
Ads