Advertisement
English transcript
You're going to start by practicing identifying errors when creating
new variables.
Now if you want to use some technical verbage, what your actually doing is
finding errors with declaring and initializing variables.
Declaring your variable means creating a new variable.
It's like making the box for a variable, and it looks like this.
Right now, there's no value involved, it's just the data type, the name,
and a semi colon.
Initializing on the other hand, is when you set an initial value for a variable.
It's that act of putting something inside the box.
And in code it looks like this.
Total = 10.
Now oftentimes you'll combine the two, both declaring and initializing and
write a code statement like int total =10.
This both creates the box and
puts the value inside the box all in one statement.
So you're going to be looking at statements like these,
which either are both a declaration and an initialization or
just a declaration and identifying when an error has been made.
Now, these errors are bad enough that they're considered compile time errors.
And what this means is that Android Studio won't even let you run your code,
because it can't understand what you're trying to say.
Let's take a look at an example of what the Part 1 problems
are going to look like.
Okay, so this is the first of the Part 1 problems,
and I'm just going to walk you through it a little bit.
Okay, so the problem states, unreadEemails is a variable storing
the number of unread emails for an inbox app.
And we're going to go ahead and assume that there are ten unread emails.
So now you're going to look at these three different
initializations/declarations.
Some or all of these will have errors.
You're just looking at the single line by itself.
This is not a block of code.
So you'll look at the first one and decide whether it's properly written
in a way that it both declares and initializes the variable unreadEmails.
If it does move on to the next one.
And if you don't think it does then put a check right here in this check box.
Now if it has an error I also want you to come over here and
describe what you think is causing the error.
Okay but i'm not necessarily saying this one has an error that was just for
an example.
Okay, so you'd go through these and
check the ones that you think have problems and
then describe what the errors are here.
If you'd like, I've provided the code for
each of these exercises in the instructor notes below.
So you can try copying them over, one at a time, and
putting them into the app that you just created for yourself.
Once you're done, I highly encourage you to go through the solution video.
I'll explain the logic behind which ones had errors.
new variables.
Now if you want to use some technical verbage, what your actually doing is
finding errors with declaring and initializing variables.
Declaring your variable means creating a new variable.
It's like making the box for a variable, and it looks like this.
Right now, there's no value involved, it's just the data type, the name,
and a semi colon.
Initializing on the other hand, is when you set an initial value for a variable.
It's that act of putting something inside the box.
And in code it looks like this.
Total = 10.
Now oftentimes you'll combine the two, both declaring and initializing and
write a code statement like int total =10.
This both creates the box and
puts the value inside the box all in one statement.
So you're going to be looking at statements like these,
which either are both a declaration and an initialization or
just a declaration and identifying when an error has been made.
Now, these errors are bad enough that they're considered compile time errors.
And what this means is that Android Studio won't even let you run your code,
because it can't understand what you're trying to say.
Let's take a look at an example of what the Part 1 problems
are going to look like.
Okay, so this is the first of the Part 1 problems,
and I'm just going to walk you through it a little bit.
Okay, so the problem states, unreadEemails is a variable storing
the number of unread emails for an inbox app.
And we're going to go ahead and assume that there are ten unread emails.
So now you're going to look at these three different
initializations/declarations.
Some or all of these will have errors.
You're just looking at the single line by itself.
This is not a block of code.
So you'll look at the first one and decide whether it's properly written
in a way that it both declares and initializes the variable unreadEmails.
If it does move on to the next one.
And if you don't think it does then put a check right here in this check box.
Now if it has an error I also want you to come over here and
describe what you think is causing the error.
Okay but i'm not necessarily saying this one has an error that was just for
an example.
Okay, so you'd go through these and
check the ones that you think have problems and
then describe what the errors are here.
If you'd like, I've provided the code for
each of these exercises in the instructor notes below.
So you can try copying them over, one at a time, and
putting them into the app that you just created for yourself.
Once you're done, I highly encourage you to go through the solution video.
I'll explain the logic behind which ones had errors.