Hello and welcome here we are this is a video about an array
this video is only going to answer two questions
what is an array and why do we need an array
this is quite an exciting moment I hope
it is for me I hope it is for you
because where are we in our journey through programming
we are now at
the very end of the fundamentals of programming
we have done variables we have done conditionals we have done loops
objects, functions, I should said functions, objects but whatever functions, objects and now we are at this last piece of the puzzle the array
once we get through this last piece of the puzzle we can move on and start to explore all sorts of interesting and exciting applications of these ideas in different directions and
and I hope to make more videos and point you towards more videos and content and exciting adventures that you may or may not choose to have
and so but all I want to do here is talk about an array
now I'm going to say if you remember where we last left off
truth of the matter is I left this off like a year ago I'm kind of filling in a video that the audio had some problems in so I'm trying to keep continuity as best as possible I do have more gray hair
and I forgot to trim this beard so
anyway wearing a different shirt but you know whatever
you will figure it out if it's a problem for you, you will email me and a slip a note somewhere handwritten in some box somewhere
okay so here we are this is where you last left off if you were watching videos this is where I last left off my memory serves me we had this beautiful lovely little nice program
what did it have it has two bubble objects those two bubble objects are initialized here and set up some functions are called with them and they're floating up to the top of the screen they're lovely I love them they make me feel happy
but and you know what this could be our world we could say
you know what we live in this wonderful little world of two bubbles and there never needs to be any more bubbles but
some sometime in your life you might choose to dream a little bit bigger
you might move forward and say I don't want two bubbles
I want 3, I want 10, I want 100, I want 1000, I want to have no bubbles when the program starts
and then after a while a couple bubbles appear then a few more we need to suddenly have the option of having many many more bubbles
so let's let's just say for a moment here's our first approach
our first approach of this problem is to say well I had two bubbles
and the way that I had two bubbles was I said bubble b1 and then I said bubble b2
perfect now I would like three bubbles so I will say bubble b3
and now what would I like for bubbles don't worry I will keep doing this forever bubble b4 and we can see that this is a reasonable solution
and it is sustainable to about I don't know maybe five bubbles maybe by the time we get to five balls would be like eye and forget it I that six bubble is just never going to happen I'm done
so we need a better solution it's quite obvious to you in your mind probably what that solution is even though we haven't done it yet
but the solution is an array
what is an array what do we want we want to have a list of bubbles
I want to just say in one statement I want to have a list of
100 bubbles or 1,000 bubbles
or 1 million bubbles right
so I wouldn't be able to have as many bubbles as I want and I want to be able to say that it in kind of, in one line of code
this, a list of something, a list of data is an array
an array is a data structure just like this is a data structure for a single bubble object b1
an array is a data structure that allows us say I want to have a list of x number, of n number of bubbles
so we're almost kind of done with this kind of introduction of the idea of an array we see why we need one that's pretty obvious
a little bit of how we have what it means conceptually
but let's take that one little step further and kind of get a peek at the syntax and then in the next video it's going to carry forth and continue this journey forward and forward and forward
okay so if you remember there was a time sometime in your life or my life or in a past video that existed somewhere where we wanted to have a number
and we would say int I could say int val equals 5 for example
I want to have a number I'm going to call it Val it's an integer and I'm gonna give it the value 5
what actually happens on the computer well we have
this thing called RAM the computer's memory the brain of the computer where all this data is stored
we open up a spot in the computer's memory we name it val
it's named val and then what do we do we store the number five there
this works now let's take the following scenario
what if we have the computer's memory and what we want to do is we want to say I don't want to open up spot for a single number
what I want to do is open up enough spots for 1 2 3 4 5 6 7; 1 2 3 4 5 6 7 numbers
and I want to name that values
I'm going to name it values and what I want values to be is a list of all these numbers
2 -5 107 4 91 3 33
right so values is a list of all those numbers
how does this work this is hopefully this makes this gives it this gives us a nice conceptually this makes sense to us
this word is is is an at is is pointing to a single number this word is pointing to a continuous list of numbers
we declared val as an integer set it equal to 5 what we need to do is declare values as a list of integers
open square bracket close square bracket let me write that again over here a little bit bigger open square bracket close square bracket
this is how we note an array in a declaration
an int a single integer val an array a list of integers an array open square bracket close square bracket
that syntax is going to come up more and more we're going to start using square brackets if you're like never got to use those keys on your keyboard here you go here's your chance
so once we have this list we can actually initialize it by saying curly bracket 2, -5, 107, 4, 91, 3, 33
so this syntax I'm less concerned about we're going to get into the details of the syntax of opening up the list filling the list using the values in the list what does it need to say like I want to take all these numbers and double them
I want to take all these numbers and divide them by 2 I want to sort these numbers so that the so that the lowest ones are at the beginning of the list these are all the kinds of things you can do with an array
for you the thing that you want to start thinking about there's no real exercise here they'll be an exercise after the next video I guess
but find that... find your bubble right what was that program that you wrote that had
thing one thing two thing three
thing four find that piece of code look at it think about what an array would
give you what possibilities would that open up and and and like have that ready
to go because that's the piece of code you're going to start to adjust as we go
through the next videos and go over the syntax more and more and more okay that
was about seven minutes that you watched or if you're still here or maybe you
just start at the middle I don't know if whatever and this is done now hopefully
the audio work because I did this video earlier in the audio was terrible and I
hope this is better okay bye