Re: Singly Linked LIst and Objects Newbie Question
xen <xen@rotmail.nl> writes:
{ public java.lang.Boolean call()
Yes, generics, all the way! Only drawback is that you can't call it
When I wrote this, I was not aware that you actually
had posted something like this in another posting.
So, I just wanted to show, that in Java, an expression
might contain statements.
You are right that the interface is not necessary:
I erroneously believed that it was nessary.
It surpirised me that you don't have to catch the Exception that's
defined on the call method in Callable; apparently such exceptions
only take effect if the implementing class specifies it.
It seems that an extension of a abstract method can restrict
the exceptions thrown. This seems to be suggested by
http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.4.3.1
It only seems to be required that
?a method declaration must not have a throws clause that
conflicts (?8.4.6) with that of any method that it overrides;?
http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.4
Also, see the example:
http://java.sun.com/docs/books/jls/third_edition/html/interfaces.html#9.4.3.1
Here is another example by me:
interface Example { void run() throws java.lang.Throwable; }
class Example1 implements Example
{ public void run(){ java.lang.System.out.println( "Example" ); }}
public class Main
{ public static void main( final java.lang.String[] args )
{ new Example1().run(); }}
Example