How are package names defined in java, why is "com" the root?

I tried this but found nothing. I'm just curious to know why we use the folder name "com" as the root directory? what does this mean? a computer? haha thank

+3
source share
4 answers

In java, the convention is to name packages prefixed with the return name of the package provider domain. For example, the foobar package developed by microsoft (which owns microsoft.com) can be called com.microsoft.foobar. If your company owns the domain "fantastic.net", you would name the package "net.fantastic.foobar".

Packages are organized on disk associated with their name, so "net.fantastic.foobar" will be in the "com / fantastic / foobar" folder.

This is a simple, low-cost way to prevent companies from creating two companies with the same name.

FWIW, "com" in the context of a domain name means "commercial", as in "trade-related". Wikipedia has more information if you're interested.

+6

, , , , , . , betterwidgets.com, com.betterwidgets.*.

Java (, , ) , ( , ), "com", "betterwidgets" .

+8

.

+2

".com" . , API.

+1

Source: https://habr.com/ru/post/1751420/


All Articles