Generate Number Format exception in java

Write a program to generate Number Format exception in java.

package Exception_demo;

import java.util.*;
public class exception_3 
{
    public static void main(String args[])
    {
        Scanner s=new Scanner(System.in);
        String s1;
        System.out.println("enter string");
        s1=s.next();
            int i=Integer.parseInt(s1);        
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *