Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

First program with usage of streams  RSS feed

 
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I've written simple program for finding anagrams and printing word + it's anagrams (if count of anagrams for it is ==  max count of anagrams in given file) . But I got the problem, because I don't know how to return output of filtered structure.
For printing my intent is to have something like that: word: anagram1 anagram2 anagram3... anagram(n)
Could you help me? This is my first program with usage of java.util.Stream so I feel a little lost for now.

 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah and don't worry. This site in URL is  link to forum for riddle fanatics  and it is safe.
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so I put
in the what's next line (33), but it is far from perfect.
Output:

 
Saloon Keeper
Posts: 9220
177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, what do you want to happen?

P.S. you can eliminate the get() in line 21, because if you use computeIfAbsent(), it returns the set you need.

This has the added benefit that you only create the new set when you really need to.
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to have program that at the end (with usage of Streams) will print something like:
word1 anagram1 anagram2
word2 anagram1 anagram2 ...

But I've already did it:

It looks nice and it seems to work
 
Stephan van Hulst
Saloon Keeper
Posts: 9220
177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also write your application like this:
 
Andrzej Zahorski
Greenhorn
Posts: 23
IntelliJ IDE Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
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!