Sorry if the title is misleading or is confusing, but here is my dilemma. I am inputting a string, and want to assign a value to each capitalized letter in the alphabet (A=1, ..
Achieve the same in a concise way by employing Java 8's lambda functions
String str = "ABCD"; int sum = str.chars() .filter(c -> c >= 'A' && c <= 'Z') .map(c -> 1 + c - 'A') .reduce(0, Integer::sum);