Host Name Vs Canonical Host Name
问题 Can anyone please explain me the difference between Host Name and Canonical Host Name? I am currently using InetAddress class to fetch host name using the IP Address. I came across these 2 APIs. So I am just wondering, which one I should opt for? 回答1: There are a few difference between the two: getCanonicalHostName() will attempt to resolve the FQDN. Therefore, you would get foo.mycompany.com whereas getHostName() might just return foo . getCanonicalHostName() will always do a reverse DNS