001package packageinterface.i; 002 003/** 004 * An interface. 005 * The methods only accept implementations that are created using this interface. 006 */ 007public interface I { 008 // By convention, all types mentioned in the public interface must be 009 // public types, even when not strictly necessary. For example, it would 010 // be allowable to declare aConstant at type pI, but javadoc is too stupid 011 // to print sensible documentation... 012 public static IFunctions f = new IFunctionsObj(); 013 public static I aConstant = new IObj(); 014 public void publicMethod(I that); 015} 016 017interface pI extends I { 018 // Package-private interfaces may mention the package-private types. 019 // Although utilityMethod is "public", it can only be called inside this 020 // package, since the interface itself is package-private. 021 public void utilityMethod(pI x); 022} 023 024class IObj implements pI { 025 public void publicMethod(I thatI) { 026 pI that = (pI) thatI; 027 this.utilityMethod(that); 028 that.utilityMethod(this); 029 } 030 public void utilityMethod(pI x) { 031 /* ... */ 032 } 033} 034 035 036