新增文件

This commit is contained in:
lixiangrong
2016-03-07 16:01:38 +08:00
parent 414edce9a4
commit efe9a4595a
4 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
/**
*
*/
package osc.git.eh3.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author lixiangrong
*
*/
@Target(ElementType.PACKAGE)
@Retention(RetentionPolicy.RUNTIME)
@interface PkgAnnotation {
}

View File

@@ -0,0 +1,18 @@
package osc.git.eh3.annotation;
import java.lang.annotation.Annotation;
public class TestPkgAnnotation {
public static void main(String[] args) {
Package pkg = Package.getPackage("osc.git.eh3.annotation");
Annotation[] annotations = pkg.getAnnotations();
for (Annotation annotation : annotations) {
System.out.println(annotation);
}
// ===========================友好类和包内访问常量==============
new MyPackageMethod().myPackageMethod();
System.out.println(MyPackageConst.PACKAGE_STRING);
}
}

View File

@@ -0,0 +1,25 @@
/**
*
*/
/**
* @author lixiangrong
*
*/
@PkgAnnotation
package osc.git.eh3.annotation;
/**
* 包内方法
*/
class MyPackageMethod {
public void myPackageMethod() {
System.out.println("MyPackageMethod...");
}
}
/**
* 包内常量
*/
class MyPackageConst {
static final java.lang.String PACKAGE_STRING = "myPackageConst";
}