-
Parts of the class not included in its public interface belong to implementation:
-
Compiler prevents users from gaining access to the class implementation.
-
Implementation is hidden from the user.
-
Java example of the interface/implementation:
public class IntSquare {
// private attribute
private int squareValue;
// public interface
public int getSquare( int value ) {
SquareValue = calculateSquare( value );
return squareValue;
}
// private implementation
private int calculateSquare( int value ) {
return value * value;
}
}
|
|