RosettaCodeData/Task/Memory-allocation/Java/memory-allocation-1.java

6 lines
355 B
Java
Raw Normal View History

2023-07-01 11:58:00 -04:00
//All of these objects will be deallocated automatically once the program leaves
//their scope and there are no more pointers to the objects
Object foo = new Object(); //Allocate an Object and a reference to it
int[] fooArray = new int[size]; //Allocate all spaces in an array and a reference to it
int x = 0; //Allocate an integer and set its value to 0