• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with lambda -> Collectors.toList of mine class  RSS feed

 
Dmytro Grytskiv
Greenhorn
Posts: 10
1
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I have code:




And I try to rewrite this loop:


to lambda expression:
listOfTLDDomainNames = Stream.of(csvReader.readNext())
                    .collect(Collectors.toList());

I have get error message:

incompatible types: inference variable T has incompatible bounds
    equality constraints: TLDDomain
    lower bounds: String
  where T is a type-variable:
    T extends Object declared in method <T>toList()
----
(Alt-Enter shows hints)
 
Dmytro Grytskiv
Greenhorn
Posts: 10
1
MySQL Database Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get a Stream of rows, it's easiest if you let whatever csvReader's class is implement Iterator<String[]>. You can then add a static method:

Create a separate method that converts a row to a TLDDomain, for instance:

You can then perform the following:

A sidenote, why is your class named TLDDomain? That effectively means Top Level Domain Domain. I would just call it TopLevelDomain.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!