package rebelsky.generics; import java.math.BigInteger; public class BigIntFun { /** * Shove a lot of stuff into a linear structure and then * take it out again. * * @pre stuff is empty */ public void oohFun(LinearStructure stuff) { for (int i = 0; i < 10; i++) stuff.put(BigInteger.valueOf(i)); stuff.put("Hello"); // Note: stuff should only contain BigIntegers while (!stuff.isEmpty()) { BigInteger bi = (BigInteger) stuff.get(); } // while } // oohFun(Linear) public void moreFun(NewLinear stuff) { for (int i = 0; i < 10; i++) stuff.put(BigInteger.valueOf(i)); // stuff.put("Hello"); // Java says "No way!" // Note: stuff should only contain BigIntegers while (!stuff.isEmpty()) { BigInteger bi = stuff.get(); } // while } // moreFun(NewLinear) public void lessFun(BIL b) { b.put("Hello"); BigInteger bi = b.get(); } } // class BigIntFun