Hi
Pages 19-22 of javainterface.pdf explains this. Basically when you  
create an interface you are defining a new type much the same as  
defining a class. Any object that implements an interface can be  
referenced by not only it's class type but also by it's interface type.

This allows you to enforce any 'contracts' that require objects to be  
not only of particular types but also implementing particular  
interfaces. So you get compile time checking, and you can also do  
things at run time like:

        if (NewClass instanceof NewInterface) {...}

Hope this helps. I'd still re-read the PDF if you're still unclear on  
this.

Cheers
Nic

On 14/12/2009, at 7:53 AM, nn roh wrote:

> Hi all,
>
> I am trying to do the homework , i didnt get this line :
>
> AddressInterface   getAddress();     how can a method return an  
> interface ? can any one elaborate ..
>
>
> Thanks,
> Nada
>
> -- 
> To post to this group, send email to 
> [email protected]
> To unsubscribe from this group, send email to 
> [email protected]
> For more options, visit this group at 
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to