Javatpoint Logo
Javatpoint Logo

Java URL getHost() Method

The getHost() method of URL class returns the hostname of the URL. This method will return the IPv6 address enclosed in square brackets ('['and']').

Syntax

Parameter

NA

Returns

the hostname of this URL.

Example 1

Test it Now

Output:

The given url is : https://www.javatpoint.com/java-threadpoolexecutor
Host name in given url is : www.javatpoint.com

Example 2

Output:

Enter any url 
https://www.javatpoint.com/java-threadpoolexecutor
Host name in given url is : www.javatpoint.com

Example 3

Test it Now

Output:

Url1: https://www.javatpoint.com/URL-class
Url2: https://www.javatpoint.com/URL-class
Both url has Same host name  
Next TopicJava URL Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA