In Java, the new keyword is used to create a new instance (object) of a class. For example, the following code creates a new object of class String:

String text = new String("Hello");

Create a new array object:

int[] numbers = new int[3]; 

Create a new instance of a class:

class Car {
}
Car newCar = new Car();

 

Related keywor: class. See all keywords in Java.

 

Other Recommended Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment