Re: Singly Linked LIst and Objects Newbie Question
On 3 Oct 2007 00:15:52 GMT, ram@zedat.fu-berlin.de (Stefan Ram) wrote:
xen <xen@rotmail.nl> writes:
you need multiple statements for to calculate,
so you can't fit it into the assert statement
public class Main
{ public static void main( final java.lang.String[] args )
{ assert new java.util.concurrent.Callable<java.lang.Boolean>()
{ public java.lang.Boolean call()
{ int a = 7;
++a;
return a == 9; }}.call();
java.lang.System.out.println( "ok." ); }}
Exception in thread "main" java.lang.AssertionError
at Main.main(Main.java:3)
Yes, generics, all the way! Only drawback is that you can't call it
with parameters. And it seems a bit unnecessary and well, useless. Why
implement an interface if it has no use AT ALL? It's not as if you're
gonna pass this object to anyone. Just a label to signify your
intention with this object? Well then you would better define your own
empty interface that doesn't place any restriction on the call method.
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.