public static <T> T cast(Object o, Class<T> type) {
if (type.isInstance(o)) return type.cast(o);
throw new RuntimeException("can not cast " + o.getClass() + " to '" + type);
}
Java将Object类型的对象转为指定的类型
猜你喜欢
转载自blog.csdn.net/daiyi666/article/details/120107673
今日推荐
周排行