Javatpoint Logo
Javatpoint Logo

Java InetAddress getLocalHost() method

The getLocalHost() method of Java InetAddress class returns the instance of InetAddress containing local host name and address. In this, firstly the host name is retrieved from the system, then that name is resolved into InetAddress.

Syntax:

Returns

It returns the instance of the local host.

Throws

UnknownHostException: if the local host name could not be resolved into an instance.

Example 1

Test it Now

Output:

10.0.0.4

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