Re: 1.5 generic question
From: Thomas A. Li (tli_at_corporola.com)
Date: 12/18/03
- Previous message: Mario_5: "Re: My mp3player without Linux support"
- In reply to: Chris: "1.5 generic question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 18 Dec 2003 18:34:44 GMT
That is what OO inheritance means.
It works one way only. Try the other direction.
"Chris" <sarge_chris@hotmail.com> wrote in message
news:568394b1.0312170319.bd4959a@posting.google.com...
> Has anyone had a play with generics in the JDK1.5 beta-release and/or
> knows the answer to this:
>
> If I have the following:
>
> // immutable
> interface Address
> {
> String getStreet() { ... }
> ...
> }
>
> // mutable
> class MutableAddress implements Address
> {
> String getStreet() { ... }
> void setStreet( String street ) { ... }
> }
>
> then using generics I could define this:
>
> private List<MutableAddress> list;
>
> but could I 'down-cast' this list to do the following:
>
> List<Address> getList() { return list; }
>
> i.e. the client will only get the immutable base-class.
>
> Any ideas?
>
> - sarge
- Previous message: Mario_5: "Re: My mp3player without Linux support"
- In reply to: Chris: "1.5 generic question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|