Welcome back.
In this video I want to show you three dimensional arrays a little more because we have created one,
but we have never initialized it and never actually accessed it.
Okay.
So I'm going to create a very small, very simple three dimensional array which I'm going to use like
so simple three d array.
And I'm just going to use curly brackets once again.
And the thing is I need three levels of curly brackets for this to work okay.
Like so.
And then I need a semicolon here at the end because we have three dimensions.
So this will be the first dimension the second dimension and the third dimension okay.
So that means that I can now separate them accordingly.
So I can go ahead and let's say have another layer like this.
So I'm just going to have very simple values here.
So this one will be 000.
This one will be 001.
And then we close this.
And this should actually not be an int.
It should be a string because then it's easier to actually read what's going on.
So here we have the first dimension.
And then let's say I have another entry.
And here this would be again 010.
And this one would be 011.
And now in this layer there we have 100.
And here we have 101.
And then let's do another one.
This one would be 110.
And this one should be 111 okay.
So you see with each dimension it becomes significantly more complex so to speak.
But if I wanted to access the first entry inside of my array, I would use the 000 index.
If I want to have the second entry, I use the 001 index and so forth.
So this is a three dimensional array where this is let's say the x axis.
This is the y axis and this is the z axis okay.
And now this is just me giving it these names.
You could obviously um give the like use the axis otherwise as well.
But this is like the first axis.
This is the second axis and this is the third axis.
So now if you wanted to access whatever is in here you would use this index ID.
So let's say I want to access this c w.
And I would just say simple 3D array at the position of 010.
That would give me this entry okay.
Let's run this and we will see how this is going to look like.
And we see we get 101.
So we did actually get the one that I was talking about.
And the statement is from earlier from understanding indexes.
So I'm trying to give you a similar feel for this dimension.
Now you could go ahead and have even more layers to it.
Right.
So you could go ahead and have another one like so where you have more values in there.
Now this would be two and everything else would stay the same.
And that is pretty much simple 3D arrays.
I would go further here, but I actually have never worked with three dimensional arrays in like real
world applications.
So I just wanted to give you a general idea as to what those 3D arrays are and how you can assign values
to them.
Now, obviously, if you wanted to overwrite a value, you could go ahead and use this again, simple
3D array.
And then you could say at which position you want to change something.
So let's say at a position of 210I want to have a new string.
Now this is going to be say hi what's up.
Okay.
So now I'm overwriting the string at 210.
So let's actually access to one zero.
Let's run this and it should say hi.
What's up okay.
So that's how you can overwrite or assign value even though we did already did initialization.
So here this is an initialized three dimensional array okay.
So that's it for this video.
See you in the next one.