0

What does the "new" keyword do?

Scanner myVar = new Scanner(System.in); //new? why?

20th Aug 2018, 3:33 PM
Time Loop
Time Loop - avatar
4 ответов
+ 6
In C++ 'new' keyword is used to create dynamic variables or containers. These dynamic variables are created on heap. The most important thing is that you need to delete the dynamic variables after their use in a program using keyword 'delete' otherwise you will have a memory leak issue
20th Aug 2018, 3:50 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 4
Firstly next time explicitly say what language you are talking about or put it in the tags. The new keyword in Java is used to tell the language to create a new object, in this case create a Scanner object that will take/scan user input when specified hence "Scanner".
20th Aug 2018, 4:11 PM
TurtleShell
TurtleShell - avatar
+ 2
what language
20th Aug 2018, 3:42 PM
Ultron
Ultron - avatar
0
Thanks guys.
21st Aug 2018, 3:28 AM
Time Loop
Time Loop - avatar