上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 34 下一页
摘要: 要求:利用注解测试某个类中的方法,并且将异常信息写入文件中 计算器类 public class Caculator { @Check public int add() { return 1 + 3; } @Check public int sub() { return 3 - 1; } @Check 阅读全文
posted @ 2021-05-04 17:34 code-G 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 自定义注解 import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.an 阅读全文
posted @ 2021-05-04 17:31 code-G 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 自定义注解 格式:public @interface 注解名称{属性列表;} 本质:注解本质上就是一个接口。该接口继承Annotation接口 public interface Myanno extends java.lang.annotation.Annotation 属性:接口中的抽象方法 属性 阅读全文
posted @ 2021-05-04 11:48 code-G 阅读(80) 评论(0) 推荐(0) 编辑
摘要: public class Caculator { public int add(int a, int b) { return a + b; } } 测试类 import mystring.junit.Object.Caculator; import org.junit.After; import o 阅读全文
posted @ 2021-05-04 10:34 code-G 阅读(67) 评论(0) 推荐(0) 编辑
摘要: //配置文件内容 className=xxx methodName=xxx import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Invo 阅读全文
posted @ 2021-05-03 22:12 code-G 阅读(317) 评论(0) 推荐(0) 编辑
摘要: import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; //通过反射越过泛型检查 public class ReflectDemo 阅读全文
posted @ 2021-05-03 22:08 code-G 阅读(48) 评论(0) 推荐(0) 编辑
摘要: import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; //通过反射获取成员方法并使用 public class ReflectDemo5 { public static void ma 阅读全文
posted @ 2021-05-03 22:07 code-G 阅读(269) 评论(0) 推荐(0) 编辑
摘要: import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; //通过反射获取成员变量 public class Re 阅读全文
posted @ 2021-05-03 22:06 code-G 阅读(626) 评论(0) 推荐(0) 编辑
摘要: import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; //暴力反射使用私有方法 public class ReflectDemo3 { public static void 阅读全文
posted @ 2021-05-03 22:05 code-G 阅读(310) 评论(0) 推荐(0) 编辑
摘要: import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; //反射获取构造方法并实例化对象 public class ReflectDemo2 { public static v 阅读全文
posted @ 2021-05-03 22:04 code-G 阅读(165) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 34 下一页