Module 10 of 12 · Text
Return new
We use:
🔹 return new Something()
When the method must return an object.
Example:
public static Person createPerson() {
return new Person("Brenda"); }
Here:
-
The return type is Person
-
So we must return a Person object
-
new Person(...) creates that object