concept new in category java

This is an excerpt from Manning's book Java SE 11 Programmer I Certification Guide.
An object comes into the picture when you use the keyword operator new. Usually Factory methods etc. can be used to create objects too. You can initialize a reference variable with this object. Note the difference between declaring a variable and initializing it. The following is an example of a class Person and a class ObjectLifeCycle:
Exam objectives covered in this chapter
What you need to know
[3.4] Creating and manipulating Strings
How to initialize String variables using String literals and new operator.
Use of the operators =, +=, !=, and == with String objects. Pooling of string literal values. Literal value for class String.
Usage of methods from class String. Immutable String values. All the String methods manipulate and return a new String object.
[3.5] Manipulate data using the StringBuilder class and its methods
How to create StringBuilder classes and how to use their commonly used methods.
Difference between StringBuilder and String classes. Difference between methods with similar names defined in both classes.
Figure 5.2 String objects created using the operator new always refer to separate objects, even if they store the same sequence of characters.
![]()

This is an excerpt from Manning's book OCA Java SE 8 Programmer I Certification Guide.
String objects that are created using the assignment operator (=) are stored in a pool of String objects, but String objects that are created using the operator new aren’t stored in the pool of String objects.
Another important point to note is that if you declare and initialize an array using two separate lines of code, you’ll use the keyword new to initialize the values. The following lines of code are correct:
int intArray[]; intArray = new int[]{0, 1};But you can’t miss the keyword new and initialize your array as follows:
You can create objects of the class String by using the new operator or by using String literal values (values within double quotes). You can assign a String literal value to a String reference variable by using the assignment operator (=). But you may have noticed a big difference in how these objects are stored and referred to by Java.
Let’s create two String objects with the value "Paul" using the operator new:
Figure 4.1. String objects created using the operator new always refer to separate objects, even if they store the same sequence of characters.
![]()