For Ex: In this program I am showing how the Scanner class is giving proper exception details.
ScanDemo.java
ScanDemo.java
import java.util.Scanner;
class ScanDemo{
public static void main(String s[] ){
Scanner scan=new Scanner( System.in );
System.out.println("\n Enter Some Boolean data: ");
Boolean a = scan.nextBoolean();
System.out.println("\n a: "+a);
}
}
class ScanDemo{
public static void main(String s[] ){
Scanner scan=new Scanner( System.in );
System.out.println("\n Enter Some Boolean data: ");
Boolean a = scan.nextBoolean();
System.out.println("\n a: "+a);
}
}
Output: