class MyProgram
{
    static void Main()
    {
        int[] integers;            // declare array
        integers = new int[10];    // size array
    }
}

In which line is the array actually instantiated?

Recommended Answers

All 4 Replies

Array get instantiated when you create it with new keyword:

integers = new int[10]; // size array

declaration can just create a reference.

int[] integers; // declare array

integers = new int[10];

Yep.. Just because you've declared a container, doesnt automagically mean its made, thefore the new keyword gives you the default contents for that type

int[] integers = new int[10];

her u put ur refrence in the stack pointed to integers[0] in the heap

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.