The new keyword is used as an operator for creating a new object or array.
When new is used to create an object, it first creates an instance of the specified class, then initializes all of the instance variables to their default values, and last invokes the appropriate constructor for the class, depending on the arguments provided in the argument list.
Using the new keyword to create a class object typically looks like this:
Button b = new Button("OK");
The new operator can also be used to allocate dimensional arrays for any numeric or object type. Once an array has adequate space allocated, all the elements of the array are initialized to a default value, and it is then up to the programmer to supply values other than the defaults.
Using the new keyword to create an array typically looks like this:
int array[] = new int[ 10 ];