Home | History | Annotate | Download | only in src
      1 public class Main {
      2     static void arrayCluster(IMagic[] magicArray) {
      3         int i;
      4 
      5         for (i = 0; i < magicArray.length; i++)
      6             System.out.println(" " + i + ": " + magicArray[i].getSomeData());
      7     }
      8 
      9     public static void main(String args[]) {
     10         MagicClass magic = new MagicClass();
     11 
     12         System.out.print("magic is ");
     13         System.out.println(magic.getSomeData());
     14 
     15         MagicClass magicArray[] = new MagicClass[2];
     16         magicArray[0] = new MagicClass();
     17         magicArray[1] = new MagicClass();
     18         arrayCluster(magicArray);
     19     }
     20 }
     21 
     22 class IntSource {
     23     public int getMagicInt() { return 64; }
     24 }
     25 
     26 interface IMagic {
     27     public double getSomeData();
     28 
     29     IntSource mIntSource = new IntSource();
     30     public int MAGIC_INT = mIntSource.getMagicInt();
     31 }
     32 
     33 class MagicClass implements IMagic {
     34     public double getSomeData() {
     35         return this.MAGIC_INT;
     36     }
     37 }
     38