+ 4

Why there are no malloc and calloc functions in java or in any other language except c ?

Please provide an example with answer

19th Jul 2018, 10:43 AM
Atharva Kadegaonkar
Atharva Kadegaonkar - avatar
3 ответов
+ 8
languages without automatic garbage collection like c and c++ have those functions to enable the user to work with memory higher level languages like java don't need those functions as they do have automatic garbage collection
19th Jul 2018, 11:41 AM
hinanawi
hinanawi - avatar
+ 8
In java ,new keyword used instead of malloc, and garbage collector instead of free. As Java manages memory for you(user) one cannot explicitly delete or free up memory instead You can explicitly set an object variable to null!
19th Jul 2018, 11:31 AM
Ashish Jog
Ashish Jog - avatar
+ 2
Thank you for the answer Ashish Jog & hinanawi 😃👍
2nd Oct 2018, 6:24 AM
Atharva Kadegaonkar
Atharva Kadegaonkar - avatar