1.5 generic question
From: Chris (sarge_chris_at_hotmail.com)
Date: 12/17/03
- Next message: Herman Timmermans: "Re: jsp tomcat problem"
- Previous message: anks: "jsp tomcat problem"
- Next in thread: Daniel Bonniot: "Re: 1.5 generic question"
- Reply: Daniel Bonniot: "Re: 1.5 generic question"
- Reply: Thomas A. Li: "Re: 1.5 generic question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 17 Dec 2003 03:19:14 -0800
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
- Next message: Herman Timmermans: "Re: jsp tomcat problem"
- Previous message: anks: "jsp tomcat problem"
- Next in thread: Daniel Bonniot: "Re: 1.5 generic question"
- Reply: Daniel Bonniot: "Re: 1.5 generic question"
- Reply: Thomas A. Li: "Re: 1.5 generic question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|