Click on item.java to get source.
import java.io.*;
public class item implements Cloneable {
public int x;
public item (int m)
{ System.out.print("item constructor with arg: ");
System.out.println(m);
x = m;
}
public item()
{ System.out.println("item constructor without arg");
x = 0; // redundant: by default is zero
}
public Object clone()
{ System.out.println("item clone method");
item it = new item();
it.x = x;
return it;
}
public void print(PrintWriter os)
{ os.print("write item obj to stream: x = ");
os.print(x);
}
public String toString()
{ CharArrayWriter buf = new CharArrayWriter();
PrintWriter os = new PrintWriter(buf);
print(os);
return buf.toString();
}
}// end class item