I understand what I am asking for in the following question has almost no practical application, but I want to know if it is possible to do in Java.
I want to be able to define athrows
declaration with two words (the first word to be ignored and the second word to be treated as a valid exception type, which it will be).
So basically I want a method signature that looks like this to compile:
public void foo() throws A Fit {}
Where the word 'A
' is simply ignored and then I would have Fit
defined as a custom exception (as you would normally do this) like:
public class Fit extends Exception {
public Fit(String msg) {
super(msg);
}
}
So in essence I am asking if I can somehow tell Java to ignore a specific textual 'keyword' (in this instance 'A
'). Thus, define keyword 'A
' to do nothing. I know you can do this in C by defining keywords via #define
, but does Java offer this capability in any way?