It looks like you've defined BinaryFormatException
as an inner class to your public class binaryToDecimal
. That means that you need an instance of binaryToDecimal
to have an instance of BinaryFormatException
. However, you are in the static
context of the parseBinary
method. There is no instance of binaryToDecimal
.
You have two choices:
- Declare the
BinaryFormatException
classstatic
. - Move the
BinaryFormatException
class code outside of thebinaryToDecimal
class.