0

If I create custom exception with a String message i have: super(message) however, i want to have a double number in my exception message. The constructor will be something like myException: my message:90.6. throw exception: throw new myException("my message", 90.6);

Here is the code i've tried but didnt works. Any help would be much appreciate.

public class myException extends Exception {

    private String message;

    private double qtyAvail;

    public myException(String message, double qtyAvail){

        super(message);

        this.qtyAvail = qtyAvail;

    }
surisava
  • 181
  • 2
  • 4
  • 11

1 Answers1

4

Why don't you do

public MyException(String message, double qtyAvail){
    super(message + " " + qtyAvail);
}
jlordo
  • 37,490
  • 6
  • 58
  • 83