 Hi guys, so in this video, we're going to be taking a look at how arrays are created and stored in memory So when we create an array in Java like sir We all know this is the syntax, but let's take a look at what the different components mean So we have here data Which is a reference And you might also see it referred to as an object Then on the right hand side, we're creating a new instance So the reference or the object data refers to an integer array containing five integer items So when the statement above executes, step number one is storing the instance So basically somewhere in memory, a block is created for storing five integer values And the base address, which is the address of the first element in the array For this example, we'll say it's 2041 The base address is what is stored in the reference data Now the second step is going to be binding the instance to the reference So we have our reference data And data holds the address 2041 And the address is represented by those triangular brackets there But a clearer way to represent how arrays are stored in memory is through our notation So with our notation, it's drawn like so We've got our reference data And then we've got our instance And also bear in mind that when we first create our instance Each item in the array is initialized to zero And then the first item in the array is accessed at index zero The next item at index one and so on and so on So basically data holds the address of the instance And that relationship is represented by an arrow like so Now let's say we want to create another array B, which is a copy of data So the syntax for that looks like so Now bear in mind, remember that data holds the address 2041 So what we're actually doing here when we write into B equals data Is we're going to be copying the address 2041 into B So B is a reference copy of data And then as I said, B holds the address 2041, which is the same address as data So basically data and B refer to the same instance And that can be represented in our notation like so So we have data, we have B, both references We have our instance here And both data and B refer to the same instance Also bear in mind that the reference count for this instance is two Because two instances, data and B refer to it Now in a case like this where we're creating a reference copy of an array The IDs of B and data will be the same So for example they could both have the ID 22 The important thing is that they'll both have the same ID Because they both refer to the same instance Now let's move over to Eclipse and take a look at how this works in action Using the Eclipse debugger Alright, so you can see here I've just prepared we have our integer array data And we have our array B, which is a copy of data And if I go ahead and just run this through the debugger We have, alright, so to step through the creation of that first array data So now you can see data has an ID of 22 And if I expand this you can see that every item in data is initialized to zero Now if I step through You can see we've created the array B And the ID is also 22 Which does demonstrate that B is simply a copy Of the array data since they share the same ID And again if I expand this here You can see that every item in B is also initialized to zero Now there is just one other note that I want to make before we finish up with this video And that's to do with null arrays So we'll just come back here Now let's say that we want to create an array A Which equals null like so Int A equals null So what this actually means is that the reference A holds the address null So the instance hasn't actually been created A just refers to null and you would just represent that like so So it's just important to be aware of how null arrays work In terms of storage and memory So that's all for this video I hope you found it helpful and thank you for watching Bye