Question: I have read the documentation, but some says it creates two objects, some says it creates one object only.

In interviews these things are asked frequently, I don't know what to say and explain how I got the answer.

How many `String` objects will be created when we write only this statement?

```
public class Test123 {
    String st = new String();
}

```

Answer: 
When you creating the String object using 

```
String s = new String(“xyz”) it will create two objects.

```

1. The **first object** will be created in java permanent heap memory as part of the argument we are passing - "XYZ" . and it will be **created in String Literal Pool**.
2. **Second object** will be **created within java heap memory** - which will be created as part of new operator.
It has nothing to do with String literals. **Every** call to `new` creates one new object on the heap.

When you do something like:

```
String st = "something";

```

the string "something" is looked-up in the String-pool, if it doesn't exist - it will be added to the pool and a reference to it will be returned. If it already exists - a reference to it will be returned.
This has nothing to do with the `new` keyword, and there isn't *any* scenario in which you'll create two Strings with a single `new` command.