how to create custom exception with a number in constructor in Java -
if create custom exception string message have: super(message)
however, want have double number in exception message. constructor myexception: message:90.6
. throw exception: throw new myexception("my message", 90.6);
here code i've tried didnt works. appreciate.
public class myexception extends exception { private string message; private double qtyavail; public myexception(string message, double qtyavail){ super(message); this.qtyavail = qtyavail; }
why don't do
public myexception(string message, double qtyavail){ super(message + " " + qtyavail); }
Comments
Post a Comment