Java URL getHost() MethodThe getHost() method of URL class returns the hostname of the URL. This method will return the IPv6 address enclosed in square brackets ('['and']'). SyntaxParameterNA Returnsthe hostname of this URL. Example 1Test it NowOutput: The given url is : https://www.javatpoint.com/java-threadpoolexecutor Host name in given url is : www.javatpoint.com Example 2Output: Enter any url https://www.javatpoint.com/java-threadpoolexecutor Host name in given url is : www.javatpoint.com Example 3Test it NowOutput: Url1: https://www.javatpoint.com/URL-class Url2: https://www.javatpoint.com/URL-class Both url has Same host name Next TopicJava URL Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India