<html><body><div dir="ltr"><div>
  
  
  
    
    </div><div><div dir="ltr">Why not use codepoints() instead, then you dont need to worry about surrogates and all methods which work on char should also exist for codepoints.</div><div dir="ltr"><br></div><div dir="ltr">(I know that’s not your point but what I am trying to say there is a reason for this API decision “char must die”. although chars() is a bit odd - maybe it’s because there is no native CharStream?)</div><div dir="ltr"><br></div><div dir="ltr">Gruss</div><div dir="ltr">Bernd </div><div id="ms-outlook-mobile-signature"><div style="direction: ltr;">-- </div><div style="direction: ltr;" dir="auto"><a href="https://bernd.eckenfels.net">https://bernd.eckenfels.net</a></div></div>
  

<div> </div><hr style="display:inline-block;width:98%" tabindex="-1"><div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif"><b>From:</b> core-libs-dev <core-libs-dev-retn@openjdk.org> on behalf of Anil <1dropaflame@gmail.com><br><b>Sent:</b> Tuesday, September 24, 2024 2:31 PM<br><b>To:</b> core-libs-dev@openjdk.org <core-libs-dev@openjdk.org><br><b>Subject:</b> Shouldn't it be easier to turn a String into a stream of chars? (perhaps the String API needs a new method)<div> </div></font></div><div dir="ltr">I was trying to solve a puzzle (see post in JavaRanch <a href="https://coderanch.com/t/784868/java/puzzling-partitioningBy-IntStream-compile-error">https://coderanch.com/t/784868/java/puzzling-partitioningBy-IntStream-compile-error</a>)<div>I found that String.chars() yields an IntStream.</div><div>Someone pointed out that to convert it into Characters, one has to do</div><div> </div><div>  Stream<Character> sc = s.chars().mapToObj(n -> (char) n);<br></div><div dir="ltr"><br></div><div>It should not take so many obscure steps like this to turn a String into a stream of chars!<br>I feel the Java API needs another method<br><br></div><div>Stream<Character> String.asChars()<br></div><div dir="ltr"><br></div><div>thanks,</div><div>Anil</div><div dir="ltr"><br></div></div>
</div><div id="ms-outlook-mobile-signature"><div><br></div><div style="direction:ltr">-- </div><div style="direction:ltr" dir="auto"><a href="https://bernd.eckenfels.net">https://bernd.eckenfels.net</a></div></div></div></body></html>