Hi all,
the author says that the code given below compiles and runs fine...just observe.
class TestBadLegacy{
public static void main(
String [] args){
List<Integer> myList =new ArrayList<Integer>();
myList.add(4);
myList.add(6);
Inserter in=new Inserter();
in.insert(myList);
/*for(Integer s: myList)
System.out.println(s);*/--some thing
}
}
class Inserter{
void insert(List list){
list.add(new String("42"));
}
}
ok......when we don't include for loop it compiles and runs fine
without any exception......n the author didn't included this for loop when she states that this code compiles and runs fine...
but I wnated to
test the code with printing the list elements so
now it gives an exception.........u might be knowing the exception.
So why its not working with print statement.........while it works without that.