Computer Science, asked by Anonymous, 1 year ago

What is the purpose of a new operator?

Answers

Answered by ajmal64
2
heyy mate...

Here's your Answer.....

The primary purpose of new operatoris to allocate memory for a variable or an object during run time. It is used instead of malloc() function. 

ajmal64: Thankss
Answered by Anonymous
11

The purpose of a new operator is to create a new object or an array .

Example :

Scanner sc = new Scanner(System.in);

In this case ,  new operator is used to create a new Scanner class.

This Scanner class could not have been created without the use of new keyword.

int a[] = new int[5];

Here an array of 5 space is created so that it can hold 5 int type values.

Hence new is used to create an object , array, etc.

Similar questions