Line no 1 and 2 gives compilation error as "Duplicate local variable". But code in line no 3 and 4 iterates for 10 times with a single string object without any error.

```
String string1 = new String("java");            //line 1
String string1 = new String("java");              //line 2

for(int i=0;i<10;i++)                        //line 3
            String string2 = new String("abc");    //line 4 

```

How does this work?