In all programming languages, an unavoidable problem is the control of names or names. Suppose you use a name in a module of a program, and another programmer uses the same name in another module. At this point, how do you differentiate two names and prevent two names from clashing with each other? This problem is especially prominent in C language. Because the program does not provide a good name management method. C + + classes, which are the basis of Java classes, use functions in a class so that they do not conflict with nested function names in other classes. However, C + + still allows global data and global functions to be used, so it is still difficult to avoid conflicts. To solve this problem, C + + introduced the concept of "namespaces" with additional keywords.
With a new mechanism, Java can avoid these problems completely. To generate a clear name for a library, a name similar to the Internet domain name is used. In fact, Java designers encourage programmers to reverse the use of their own Internet domain names because they are definitely unique. Since my domain name is bruceeckel.com, my utility library can be named Com.bruceeckel.utility.foibles. After the domain name is reversed, the point number can be imagined as a subdirectory.
In Java 1.0 and Java 1.1, the domain extension, com,edu,org,net, and so on are all in uppercase. So the look of the library becomes: COM.bruceeckel.utility.foibles. However, in the development of Java 1.2, designers found that doing so would create some problems. So the whole package at present is based on lowercase letters.
This special mechanism of Java means that all files are automatically present in their own namespaces. And each class in a file automatically obtains a unique identifier (of course, the class name in a file must be unique). So there is no need to learn special language knowledge to solve this problem-language itself has helped us to take care of this.