debug7_2.java
来自「北京大学出版社的」· Java 代码 · 共 29 行
JAVA
29 行
package questions.c7;
class Debug7_2_Base {
private int x;
int getX() {
return x;
}
public void setX( int newX ) {
x = newX;
}
}
public class Debug7_2 extends Debug7_2_Base
implements Cloneable {
StringBuffer sb
= new StringBuffer( "Inventory count" );
public Object clone()
throws CloneNotSupportedException {
Debug7_2 result = new Debug7_2();
result.sb
= new StringBuffer( this.sb.toString() );
return result;
}
public static void main( String[] args )
throws CloneNotSupportedException {
Debug7_2 a = new Debug7_2();
a.setX( 300 );
Debug7_2 b = (Debug7_2) a.clone();
System.out.println( b.sb + " " + b.getX() );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?