Also, to print out the result, the program uses System.out.println where it.next() gives an object of DoorKeys. To print out, this object is implicitly converted to String
using toString() and since toString() method is overriden here to print out the result between "[" and "]", the value is printed out as . Had the toString() method not been overriden, the result would have been plain vanilla 2.
[ February 26, 2006: Message edited by: Ruchir Ghildiyal ]