Nhảy tới nội dung

Packages

Packages provide organization.

package com.huytunguyenn.animals;

interface Animal {
}

Naming convention:

  • all lowercase
  • use reverse domain name notation to assure global uniqueness
  • add further qualifiers to assure uniqueness within a company or group

Type names are qualified by their package, e.g. com.huytunguyenn.create.Main.

It also affects source code organization:

src
|__com
|__huytunguyenn
|_______create
|____Main

Import

Put the source code for a class, interface, enumeration, or annotation type in a text file whose name is the simple name of the type and whose extension is .java.