Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35490
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Java 8 Lambda with generic types |
| Date | 2016-08-28 13:22 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <npv6l1$9c8$1@gioia.aioe.org> (permalink) |
| References | <df44fc1a-9d48-4ba8-890e-a687d24062a9@googlegroups.com> <9ff6ad3e-bb82-4207-91d8-f03c707a1dcf@googlegroups.com> |
On 8/28/2016 10:45 AM, Stone Zhong wrote:
> Having checkToy take generic parameter is a workaround, but it does not solve the problem which it does not work with <?>. For example, if you have:
>
>
> public static void checkToys(Toy<?> ... toys) {
> }
>
> You cannot put a generic type here for checkToys, and you cannot call
>
> checkToys(
> () -> Arrays.<Integer>asList(10),
> () -> Arrays.<String>asList("hello")
> );
>
> But you can do
>
> checkToys(
> new Toy<Integer>() {
> @Override
> public List<Integer> get() {
> return Arrays.<Integer>asList(1, 2, 3);
> }
> },
> new Toy<String>() {
> @Override
> public List<String> get() {
> return Arrays.<String>asList("a", "b", "c");
> }
> }
> );
@SuppressWarnings("rawtypes")
public static void checkToys(Toy ... toys) {
Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Java 8 Lambda with generic types Stone Zhong <stone.zhong@gmail.com> - 2016-08-27 23:50 -0700
Re: Java 8 Lambda with generic types Stone Zhong <stone.zhong@gmail.com> - 2016-08-28 00:02 -0700
Re: Java 8 Lambda with generic types Arne Vajhøj <arne@vajhoej.dk> - 2016-08-28 07:46 -0400
Re: Java 8 Lambda with generic types Steven Simpson <ss@my.domain.invalid> - 2016-08-28 15:00 +0100
Re: Java 8 Lambda with generic types Lew <lewbloch@gmail.com> - 2016-08-30 22:25 -0700
Re: Java 8 Lambda with generic types Steven Simpson <ss@my.domain.invalid> - 2016-08-31 17:19 +0100
Re: Java 8 Lambda with generic types Steven Simpson <ss@my.domain.invalid> - 2016-08-28 08:19 +0100
Re: Java 8 Lambda with generic types Stone Zhong <stone.zhong@gmail.com> - 2016-08-28 03:26 -0700
Re: Java 8 Lambda with generic types Stone Zhong <stone.zhong@gmail.com> - 2016-08-28 07:45 -0700
Re: Java 8 Lambda with generic types Arne Vajhøj <arne@vajhoej.dk> - 2016-08-28 13:22 -0400
Re: Java 8 Lambda with generic types Stone Zhong <stone.zhong@gmail.com> - 2016-08-28 07:57 -0700
Re: Java 8 Lambda with generic types Stone Zhong <stone.zhong@gmail.com> - 2016-08-28 10:43 -0700
Re: Java 8 Lambda with generic types Arne Vajhøj <arne@vajhoej.dk> - 2016-08-30 20:35 -0400
Re: Java 8 Lambda with generic types Stone Zhong <stone.zhong@gmail.com> - 2016-09-02 15:18 -0700
csiph-web