Chinaunix首页 | 论坛 | 博客
  • 博客访问: 199191
  • 博文数量: 69
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 720
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-03 11:35
文章分类

全部博文(69)

文章存档

2011年(13)

2010年(46)

2009年(10)

我的朋友

分类: Java

2010-07-13 11:28:18

JLS100712Note on JLS, Ch7

 

@ http://zcatt.cublog.cn

 

Hist:

1007012, draft

 

 

 

Chapter7 Packages()

Programs are organized as sets of packages. Each package has its own set of names for types, which help to prevent name conflict.

 

Package Members

The members of a package are its subpackages and all the top level class types and top level interface types declared in all the compilation units of the package.

A package may not contain two members of the same name, or a compile-time error results.

 

Host Support for Packages

Host determines how packages, compilation units, and subpackages are created and stored, and which compilation units are observable in a particular compilation. Packages can be stored in a file system or db.

 

Compilation Units

CompilationUnit is the goal symbol for the syntactic grammer of Java programs.

 

Package Declarations

A compilation unit that has no package declaration is part of an unnamed package. An unnamed package cannot have subpackages. An implementation of the Java platform must support at least one unnamed package.

 

Import Declarations

 

Single-Type-Import Declaration

such as

import java.util.Vector;

 

Type-Import-on-Demand Declaration

such as

import java.util.*;

 

Single Static Import Declaration

A single-static-import delcaration imports all accessible static members with a given simple name from a type.

such as

import static java.lang.System.out;

 

Static-Import-on-Demand Declaration

such as

import static java.lang.System.*;

 

Automatic Imports

Each compilation unit automatically imports all of the public type names declared in the predefined package java.lang, as if the declaration:

import java.lang.*;

 

Top Level Type Declarations

A top level type declaration declares a top level class type or a top level interface type. By default, the top level types declared in a package are accessible only within the compilation units of that package, but a type may be declared to be public to grant access to the type from code in other packages.

 

Unique Package Names

REF

1.       JLS 3nd

2.       JVM 2nd
Locations of visitors to this page

阅读(988) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~