一.@Resource注解的官方解释@Resource annotation, which is semantically defined to identify a specific target component by its unique name, with the declared type being irrelevant for the matching process. 翻译:@Resource,它在语义上被定义为通过其唯一的名称来标识特定的目标组件,其中声明的类型与匹配过程无
使用基本类型的包装对象,好处可以为空且可以序列化 package com.tj; public class MyClass2 { public static void main(String[] args) { // 为每一个原始类型创建包装对象 Boolean refBoolean = new Boolean(true); Byte refByte = new Byte((byte) 123); Character refChar = new Character('x'); Short ref
原始类型和包装类型 //首先创建两个实体类 user 和 address user中包含address package cn.jbit.bean; public class User { //用户类 private String name; //姓名 private int age; //年龄 private Address address;//住址 public Address getAddress() { return address; } public void setAddress(Ad
java5之后对原始数据类型如int.char.long等基本数据类型有自动打包成相应的复合类型Integer.Character.Long等的机制:也可以将复合类型自动转换为原始类型. 这取决于程序要进行怎样的处理.如: int i = 0; Integer obj = i; ----- Integer obj = new Integer(0); int i = obj; 但是并不是所有的地方都会进行自动的打包和解包. 有些地方存在“陷阱”,不注意的话,会产生问题.如: java.util包中