Javatpoint Logo
Javatpoint Logo

Java InetAddress getHostName() method

The getHostName() method Java InetAddress returns the host name of a corresponding IP address. If this InetAddress was created with a host name, this host name will be remembered and returned else a reverse name lookup will be performed and the result will be returned based on the system configured name lookup service.

Syntax:

Returns

It returns the host name for this IP address, or if the operation is not allowed by the security check, the textual representation of the IP address

Example 1

Test it Now

Output:

DESKTOP-6FMEL47

Next TopicInetAddress 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