[b]public class DataTransfer {
private static DataTransfer dataTransfer;
static{
//在静态代码块中初始化DataTransfer对象
dataTransfer = new DataTransfer();
}
/** default constructors */
private DataTransfer()
{
}
/**
* 单态模式获取DataTransfer对象
* @return DataTransfer对象
*/
public static DataTransfer getInstance()
{
return dataTransfer;
}
}[/b]
private static DataTransfer dataTransfer;
static{
//在静态代码块中初始化DataTransfer对象
dataTransfer = new DataTransfer();
}
/** default constructors */
private DataTransfer()
{
}
/**
* 单态模式获取DataTransfer对象
* @return DataTransfer对象
*/
public static DataTransfer getInstance()
{
return dataTransfer;
}
}[/b]