• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with lambda -> Collectors.toList of mine class

 
Greenhorn
Posts: 10
1
Netbeans IDE MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic