public class RandomObjectValue { public static <T> T getObject(Class<?> clazz) { T t = null; if (clazz == null) { return t; } if((t = (T)getPrimitive(clazz))!= null){ return t; } //需要有无参的构造器 try { t = (T)clazz.newInstance(); } catch (Instantia
1.静态变量 2.静态代码块 3.局部代码块 4.构造函数 5.普通代码块 6.静态方法 7.普通方法 8.普通属性 for example: package com.JavaTest2; public class Test extends Test2 { public String j = "子类变量"; public static String i = "子类静态变量"; static { System.out.println("子类静态代码块&quo
public static void main(String[] args) throws Exception{ User user = new User(); user.setUid(25); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setJsonPropertyFilter(new PropertyFilter() { @Override public boolean apply(Object source, String k
前言 最近在读<Thinking in Java>,看到这样一段话: Primitives that are fields in a class are automatically initialized to zero, as noted in the Everything Is an Object chapter. But the object references are initialized to null, and if you try to call methods for an