<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div class="moz-cite-prefix">On 23/08/2025 20:36, Daniel Tavares
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CABeNBo3Tic0vPG6RBDd+7QX49RM-L90Drh_D5QrHSZQPhWT+HQ@mail.gmail.com">
<div dir="ltr">:
<p><b>Proposed Method</b></p>
<p>default T getRandom() {<br>
if (isEmpty()) return null;<br>
int index = ThreadLocalRandom.current().nextInt(size());<br>
return get(index);<br>
}</p>
</div>
</blockquote>
Add Lists that are mutable and support concurrent access to your
list to think about. These implementations would need to be updated
to implement this method, otherwise you risk getting IOOBE with the
default method.<br>
<br>
-Alan<br>
</body>
</html>