易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVA annotation入门

最近对spring源码感兴趣,今天看到annotation部分,略记之。
一. 最常见的annotation
@Override:用在方法之上,用来告诉别人这一个方法是改写父类的
@Deprecated:建议别人不要使用旧的API的时候用的,编译的时候会用产生警告信息,可以设定在程序里的所有的元素上.
@SuppressWarnings:暂时把一些警告信息消息关闭
@Entity:表示该类是可持久化的类
 
二. 设计一个自己的Annotation
      先看代码再讲话
1. 只有一个参数的Annotation实现
 
view plaincopy to clipboardprint?
package chb.test.annotation;  
import java.lang.annotation.Documented;  
import java.lang.annotation.ElementType;  
import java.lang.annotation.Retention;  
import java.lang.annotation.RetentionPolicy;  
import java.lang.annotation.Target;  
@Target(ElementType.TYPE)  
@Retention(RetentionPolicy.RUNTIME)  
@Documented 
public @interface MyAnnotation1 {  
        String value();  

package chb.test.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyAnnotation1 {
        String value();
}
 
2. 有两个参数的Annotation实现
 
view plaincopy to clipboardprint?
package chb.test.annotation;  
import java.lang.annotation.Documented;  
import java.lang.annotation.ElementType;  
import java.lang.annotation.Retention;  
import java.lang.annotation.RetentionPolicy;  
import java.lang.annotation.Target;  
@Target(ElementType.METHOD)  
@Retention(RetentionPolicy.RUNTIME)  
@Documented 
public @interface MyAnnotation2 {&


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

java中获得当前文件大小


根据制定路径,可以获取当前正在操作的文件的大小,容量为byte.
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FileByte {
private String filePath = "D:\\test.mdb";
private void getFileByte(){
& ......

java初学者必读 经验总结

 1:jdk开发中系统环境变量设置:  
  方法如下:  
  Win2000中:  
  右键我的电脑--》属性--》高级--》环境环境变量  
  classpath=.;jdk安装目\lib  
  path=jdk安装目录\bin  
  注意:一定不可忽略“.”。  
  ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号