0
How to create an Exception of Number format exception
Exception handling
6 Antworten
+ 2
🅰🅹 🅐🅝🅐🅝🅣 Can this be a example?
public class Program
{
public static void main(String[] args) {
int a=63;
System. out. print(a/0);
}
}
+ 2
Okay so I have to treat number and arithmetic exception differently?
+ 1
Arnold Pitso
Just try to convert string to integer. You will get that exception.
Just do this
String name = "AJ";
int n = Integer.parseInt(name);
+ 1
Atul it is an ArithmeticException not NumberFormatException.
+ 1
Atul
That's ArithmeticExcpetion - when you divide any number with 0
NumberFormatException - When you try to convert a non numeric value to numberic.
but String name = "12345"; will not give exception.
0
Atul
Yes