Last Updated: June 6, 2026
Before any networking code can talk to a remote machine, it needs a way to identify that machine. On the internet, machines are identified by IP addresses, but humans use hostnames like payments.stripe.com or cdn.shop.example. Somewhere in between, the JVM has to translate one into the other. java.net.InetAddress is the class that holds the result of that translation and exposes a small API for working with IP addresses, whether they were resolved from a hostname or supplied directly as a numeric string.
This lesson covers what an InetAddress represents, the four common ways to obtain one, the methods that inspect it, the split between Inet4Address and Inet6Address, and the DNS lookup behavior the class wraps. Sockets, URLs, and HTTP do not appear here. This chapter is purely about identifying a host.