我收到一个错误,因为try'没有'catch'、'finally'或资源声明,我如何在下面的代码中解决这个问题

public class Test{
    public static void main(String[] args) {
        try 
        {
            int i= Integer.parseInt(args[0]);
            System.out.println(i);
            }
        System.out.println("Wipro");
        catch(NumberFormatException e) 
        {
            System.out.println(e);
        }
    }
}

回答

您不能System.out.println("Wipro")try和之间插入catch。它大概应该在try. 喜欢,

public static void main(String[] args) {
    try {
        int i = Integer.parseInt(args[0]);
        System.out.println(i);
        System.out.println("Wipro");
    } catch (NumberFormatException e) {
        System.out.println(e);
    }
}


以上是我收到一个错误,因为try'没有'catch'、'finally'或资源声明,我如何在下面的代码中解决这个问题的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>