Upload files to "OOP/Java/Lab/Week10"
This commit is contained in:
parent
22f306573d
commit
0b8cfc509f
5 changed files with 162 additions and 0 deletions
17
OOP/Java/Lab/Week10/numberformatexception.java
Normal file
17
OOP/Java/Lab/Week10/numberformatexception.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
import java.util.*;
|
||||
public class numberformatexception {
|
||||
public static void main(String[] args) {
|
||||
int a;
|
||||
Scanner in=new Scanner(System.in);
|
||||
System.out.print("Input:");
|
||||
try{
|
||||
a=Integer.parseInt(in.nextLine());
|
||||
System.out.println("Number entered is "+a);
|
||||
}
|
||||
catch(NumberFormatException e)//As NumberFormatException is typecasting error
|
||||
{
|
||||
System.out.println("Error:"+e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue