package com.ddj;
import java.util.*;
/** Using the @Override annotation. @author J. Benton */
public class OverrideExample implements Collection {
// ...
/** This won't work! I'm not overriding anything here!
* This is a new method--not one being overridden.
* @param index The index of the thing to get.
* @see java.util.List#get(int)
*/
@Override
public Object get(int index) {
Object value = null;
// code to get stuff.
return value;
}
// ...
}
Example 4: Using the @Override annotation.
Back to Article