Use java.net.URI when identifying resources without relying on URL.equals() or URL.hashCode(). URL comparison may resolve host names through a network request, causing delays and treating unrelated virtual-hosted sites as equal. section 7.3 section 7.15
Avoid URL-based collection identity
Prefer URI values when resource identifiers will be compared or stored in sets and maps. Do not invoke equals() or hashCode() directly on URL objects. section 7.3
List<URL> urlList = List.of(…);
URL urlToFind = new URL("https://example.com");
if (urlList.contains(urlToFind)) {
System.out.println("Found");
}
Check list membership carefully: contains() can invoke URL.equals() indirectly even when creating the list does not. section 7.3








