I am learning Java, and the book I am reading has the following example of cloning. In clone() my first instance can set a buffer for a new object, even if the buffer is private . It seems like this requires the field to be protected for this.
Why is this allowed? Does clone() special privileges that allow it to access private fields?
public class IntegerStack implements Cloneable { private int[] buffer; private int top;
source share