{the=1, bats=2, act=3, cat=3, tac=3, tabs=2, is=1}
You appear to be trying to do too many things all at once. That sounds as though you are trying to identify words which are strict anagrams of each other. Are you also trying to categorise words by length?Atul More wrote:. . . words which have the same length and characters. . . .
The whole idea of the Stream API was to allow iteration without needing loops. You can create a Stream<Stream<String>> or similar, yes. You can use that sort of concept to sort things by length, yes. But maybe you should't try that at first. Try working out how to identify anagrams. I think you are well on your way to that. Remember that two words which are anagrams of each other always have the same length.2. How to use streams in multiple for loops?
Do you own the work.com domain? Only use that sort of package name if you own the domain you have named.. . .. . .
You appear to be trying to do too many things all at once. That sounds as though you are trying to identify words which are strict anagrams of each other. Are you also trying to categorise words by length?
Stephan van Hulst wrote:
strings.collect(
Collectors.groupingBy(
string -> Arrays.asList(
string.codePoints().sorted().toArray()
)
)
)
[/code]
Yes, but you cannot use the same Stream twice; you may need to create two Streams.Atul More wrote:. . . I am iterating the same list twice.
Is it possible to do it using streams? . . .
Yes, but you cannot use the same Stream twice; you may need to create two Streams.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |