RFR 8170348: Appendable.appendN(char, int) method to append multiple copies of char

Peter Levart peter.levart at gmail.com
Thu Dec 8 08:28:03 UTC 2016



On 12/07/2016 11:28 PM, Roger Riggs wrote:
> AbstractStringBuilder:
>    I agree with Claes' comment suggesting that IAE for negative 
> lengths is a pain
>    and defining it to append 0 would be natural in many use cases. 

OTOH, inserting a simple Math.max(n, 0) instead of n where n could get 
negative would achieve the same without complicating the expression too 
much. Java standard APIs have a tradition of being explicit rather than 
having implicit hidden logic which surely shortens many usecases, but 
makes them harder to read and understand for casual readers not 
intimately familiar with such API. The logic to treat negative lengths 
as 0 is implicit and not universally correct.

Regards, Peter



More information about the core-libs-dev mailing list