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 began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment