四种得到java对象的方法
new一个对象可能非常熟悉,但由于反序列化,反射,克隆在开发中用得不多,有些会生疏。先定义一个简单的HelloBean,他有一个接口IHelloBean,还有会抛出异常NullNameException。
<div style="">http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifpackage com.kompakar.tutorial.object.common;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gifimport java.io.Serializable;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif//接口继承Cloneable,Serializable,可以用来克隆和序列化
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gifpublic interface IHelloBean extends Cloneable,Serializable{
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif String echoHello(String name) throws NullNameException;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif IHelloBean clone() throws CloneNotSupportedException;
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif String getName();
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif}
http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif
页:
[1]