URI uri = new URI("https://www.example.com"); URL url = uri.toURL();
URI uri = new URI("https://www.example.com/search?query=java"); URL url = uri.toURL();This example creates a new URI object representing a search query for "java" on the website https://www.example.com and converts it to a URL using the toURL() method. The resulting URL object can be used to access the search results. The java.net.URI class is part of the Java Standard Library and does not require any additional package libraries.