I have following code running in 2 different environments. First environment is development environment in Eclipse with Java 7 using Java 6 compliance to run my webapp. And other is my development server running Java 6. Following code throws NullPointerException on development server, but not on my development environment. Can someone explain why this is happening?
List<String> list = null;
for(String s : list)
{
// do something
}
This will always throw an exception. What is more likely is that something is failing in one environment and the value is null and not failing in another environment where it is not null.