- 浏览: 311647 次
- 来自: ...
最新评论
-
woodding2008:
太棒了,无规则不成方圆,收藏
Google Java编程风格指南 -
qlc2008:
就是说实体类实现了这个接口,就可以完成数据库字段到对象的转换
Spring JdbcTemplate 查询方法中的RowMapper实现汇总 -
jiewuzhe02:
很好呀。。。。
Spring JdbcTemplate 查询方法中的RowMapper实现汇总 -
yangpanwww:
哈哈 问题解决了。。。 你真好!谢谢。。。
Spring JdbcTemplate 查询方法中的RowMapper实现汇总 -
xo_tobacoo:
简单清晰!Thank you !
Spring JdbcTemplate 查询方法中的RowMapper实现汇总
文章列表
finally的一些特性
- 博客分类:
- java基础
public class FinallyTest {
public static void main(String[] args) {
System.out.println("test1:" + testFinal1());
System.out.println("test2:" + testFinal2());
System.out.println("test3:" + testFinal3());
System.out.println("test4:" + testFinal4() ...
import java.util.*;
public class Generics {
//无限制的通配符类型
static int numElementsInCommon(Set<?> s1, Set<?> s2) {
int result = 0;
for (Object o : s1)
if (s2.contains(o))
result++;
return result;
}
private Map<Class<?>, Object> favorites =
new Ha ...
public class InnerTest {
public static void main(String[] args) {
//必须先有外部类的对象才能生成内部类的对象,因为内部类的作用就是为了访问外部类中的成员变量
Outer.Inner in = new Outer().new Inner(); //out.new Inner()
in.show();
in.show1();
new Outer().show2();
new Outer().show3(166);
Test test = new Oute ...
java Reflection反射
- 博客分类:
- java基础
import java.lang.reflect.*;
public class Reflection {
public static void main(String[] args) {
ReflectPerson p = new ReflectPerson("chenzq", 20);
Class<? extends ReflectPerson> c1 = p.getClass();
System.out.println(c1);
Class<String> c2 = String.class;
...
jdk动态代理生成的代理类模拟
- 博客分类:
- java动态代理
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.UndeclaredThrowableException;
public class BusinessProxyGenerateByJdk extends Proxy implements Business {
private static final long serialVersionUI ...
java 多线程编程(生产者和消费者)
- 博客分类:
- java基础
public class ProducerAndConsumer {
public static void main(String[] args) {
Storage storage = new Storage();
Thread producer1 = new Thread(new Producer(storage, "producer1"));
Thread producer2 = new Thread(new Producer(storage, "producer2"));
Thread produ ...
java类成员初始化顺序
- 博客分类:
- java基础
public class InitialOderExtends extends Parent {
// 静态变量
public static String s_StaticField = "subclass--static variable";
// 变量
public String s_Field = "subclass--variable";
// 静态初始化块
static {
System.out.println(s_StaticField);
System.out.println(&qu ...
用enum代替int常量
- 博客分类:
- effective java
public class EnumObject {
public static void main(String[] args) {
double x = 1.11;
double y = 2.01;
for (Operation op : Operation.values())
System.out.printf("%f %s %f = %f%n", x, op, y, op.apply(x, y));
System.out.println(Operation.valueOf("MINUS"). ...
避免创建不必要的对象
- 博客分类:
- effective java
public class AutoBoxing {
public static void sum() {
long start = new java.util.Date().getTime();
//使用基本数据类型
long sum = 0L;
for(long i = 0; i < Integer.MAX_VALUE; i++) {
sum += i;
}
long end = new java.util.Date().getTime();
System.out.println("total = &quo ...
java Annotation注解
- 博客分类:
- java基础
import java.lang.annotation.*;
import java.lang.reflect.*;
public class Annotation {
public static void main(String[] args) {
int tests = 0;
int passed = 0;
Class<?> testClass = AnnotationTest.class;
for (Method m : testClass.getDeclaredMethods()) {
if (m.isAnnotationP ...
java for循环使用标签以及switch
- 博客分类:
- java基础
public class LabeledLoop {
public static void main(String[] args) {
int i = 0;
outer: // Can't have statements here
for(; true ;) {
inner: // Can't have statements here
for(; i < 10; i++) {
prt("i = " + i);
if(i == 2) {
prt("continue");
...
import java.lang.reflect.Method;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
//直接使用代理类的父类作为目标业务对象。
public class BusinessCglibProxy1 implements MethodInterceptor {
private st ...
import java.lang.reflect.Method;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.CallbackFilter;
public class BusinessCglibProxyFilter {
private static C ...
java普通代理模式
- 博客分类:
- java动态代理
public interface Business {
public void service();
public void execute();
}
public class BusinessImpl implements Business {
private String id = "default";
public BusinessImpl() {}
public BusinessImpl(String id) {
this.id = id;
}
@Override
public void service( ...
cglib动态代理实现(持有业务类对象)
- 博客分类:
- java动态代理
import java.lang.reflect.Method;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
//传入业务类实例作为目标对象。
public class BusinessCglibProxy2 implements MethodInterceptor {
//拦截器持有真正的业务对象
private Object target;
private Bus ...