I'm Calin Baenen – AKA KattyTheEnby – a programmer born October 30th, 2006.
I love programming, it has been my passion since I was a kid, and will forever be my passion.
Yes, but it must be a subclass of the original return type, and I seen this.
But, I don't think void has any subclasses, and I don't think you can subclass void (even though void IS a class (void.class proves)).
I'm Calin Baenen – AKA KattyTheEnby – a programmer born October 30th, 2006.
I love programming, it has been my passion since I was a kid, and will forever be my passion.
No, because Runnable implies it's a piece of code that's run (one that's not seeking a result), much to the likes of Thread (which implements Runnable).
If Runnable was useless, it wouldn't have been made.
I want my class to be considered part of Runnable because it matches the format with similar (if not (essentially) the same) methods, and because a lot of things use Runnable in place of functions in Java.
In a subclass, you can override the return type of a method: stackoverflow.com/a/14694885
Yes, but it must be a subclass of the original return type, and I seen this.
But, I don't think
voidhas any subclasses, and I don't think you can subclass void (even thoughvoidIS a class (void.classproves)).Exactly, nothing extends
void. I am not sure of what you want to do but could java.util.function.Supplier be a better suited interface thanRunnable?No, because
Runnableimplies it's a piece of code that's run (one that's not seeking a result), much to the likes ofThread(which implementsRunnable).If
Runnablewas useless, it wouldn't have been made.I want my class to be considered part of
Runnablebecause it matches the format with similar (if not (essentially) the same) methods, and because a lot of things useRunnablein place of functions in Java.Note that a runnable doesn't 'return' void. What the 'void' return type means is that it doesn't return something.
Things like Supplier, Consumer and Function are used as much as Runnable.