I already read this related post. When it comes to string operations, the threads seem to attract a huge amount of ceremony. If you want to parse String as a stream of characters in which you can perform some operations, you first need to convert them to IntStream and then to an Object map, and then drop the int to char , eventually casting the char to String , and then return it .
And people say persistent style programming has overhead. Please correct me if I completely do it wrong. My intention is not to mock, but to better understand Java threads, because I generally appreciate them.
// Simple method which encrypts all chars in a string String input = "Hel!lo"; String result = input.chars() // Need to convert into an IntStream .mapToObj(e -> Character.toUpperCase((char) e)) // Need to map to Object (!) and then cast to char .map(CryptoMath::encryptChar) // Calling the encryption .map(String::valueOf) // Need to cast to String again... .collect(joining("")); // Finally done System.out.println(result);
source share