[Java] Object.clone()

0

Zastanawia mnie jedno - dlaczego w Javie nie moge wywolac metody clone() z dowolnej klasy tylko musze implementowac Cloneable()? Nie jest tak ze metody protected sa widoczne dla podklas? Mi wyskakuje komunikat ze ta funkcja jest niedostepna z mojej klasy? O co w tym chodzi?

0

public interface Cloneable

A class implements the Cloneable interface to indicate to the Object.clone() method that it is legal for that method to make a field-for-field copy of instances of that class.

Attempts to clone instances that do not implement the Cloneable interface result in the exception CloneNotSupportedException being thrown.

The interface Cloneable declares no methods.

1 użytkowników online, w tym zalogowanych: 0, gości: 1