I have read many artiles regarding string interning.

If I create a String object 

**Method 1**

```
  String str= new String("test")

```

2 Objects are created one in heap and other in string pool.

**Method 2 if method 1 is not executed**

```
  String str= new String("test").intern() 

```

it will create a copy of string frpoom heap to string pool .How many objects will be created.I guess 3.One will be in heap ,other in pool and one "test" literal.

Which one will be eligible for GC in both cases.I have seen artilces that say 2 are getting created but i am unable to understand why?

**Method 3**

```
    String s= new String("test")
    String s1=s.intern()

```

It does the same thing except the s point to heap object and s1 to pool object and none of them are eligible for Gc.

Is my understanding correct???I am confused a lot on this concept.