Java 创建 Costum 异常,这是链接 --> https://codecheck.io/files/wiley/codecheck-bj-4-io-110

问题描述 投票:0回答:1

https://codecheck.io/files/wiley/codecheck-bj-4-io-110

这是一个代码检查练习,

我们必须创建服装练习,但我找不到方法

java.lang.NullPointerException

我总是遇到这个错误

我试过这个

` 公共类 IllegalNumberOfWheels 扩展了 RuntimeException // TODO: 从适当的异常继承

{
  /**
   TODO: Create two constructors: one with no parameters, and one
   that accepts a message string describing the reason for the exception.
   */
   public IllegalNumberOfWheels()
   {
      
   }
   public IllegalNumberOfWheels(String msg)
   {
      super(msg);
   }
   
}`
java exception error-handling try-catch
1个回答
0
投票

你只需要

extend Exception
:

public class IllegalNumberOfWheels extends Exception
© www.soinside.com 2019 - 2024. All rights reserved.