So at the first instance variable is going to be of type string and the name of this instance variable
is computer computer name semicolon.
And then let me show you the emulator here.
So the first one is computer name as you can see here.
And then we need to actually create another instance variable which is for computer power.
So this instance variable is going to be our third integer computer power semicolon.
And here we have computer speed.
So here I can say ain't computer speed semicolon.
And make sure to also declare them and declare them as private.
So use this private access modifier for this instance variables.
So private stream computer name private int a computer power private in a computer speed and an instance
variable is for this one computer run.
So here I can say private in computer ram semi-colon.
And the next one is computer screen.
So private
strange computer screen semi-colon.
The next one is keyboard computer keyboard.
So private strange computer keyboard semicolon and the next one is computer CPQ.
So here I can say again private strange computer CPQ semicolon.
So now we have this instance variables.
So let's actually create an empty constructor for this class because we need it.
If you want to actually use it inside of an activity class because of you want to store our values to
these instance variables and we want to actually just send these values to the firebase.
So let's actually create an empty constructor so public.
And again the name of the constructor must be the same as the name of the class.
Public computer.
And then here I just need to put up a pair of Prentice's here.
I should be an empty parenthesis.
And then I need to open and close this constructed by using these curly braces.
So this is going to be an empty constructor.
Right.
And now let's actually create another constructor so that we can actually initialize our instance variables
inside our constructor.
So here inside this class inside this computer class just right click here and then click on generate
and then click on constructor and here select all these instance variables just press the shift key
on your keyboard and just select all these instance variables and then click on OK.
So now as you can see we have actually a constructor here that is created automatically by yantra studio
for us.
So let me actually create a newline character here so that you can see these values here.
So we have actually a constructor and this construction accepts some arguments.
The first one is computer name which is of type string.
The second argument is actually of the integer and is computer power.
The first argument is computer speed which is an integer.
And we have this computer RAM which is of type integer computer screen screen and computer keyboards
training.
And finally we have this computer Sibiu which is of type string.
And inside the curly braces of this constructed as you can see here we are actually initialising which
are instance variables.
So this computer name refers to this computer name here right.
Assignment operator computer name this computer power assignment operator computer power.
And here T-stat computer speed assignment operator computer speed.
So he had this current data computer the refers to these computers here that we have and this that computer
ram time assignment operator computer ram as you can see here.
This computer screen assignment operator computer screen this that computer keyboard assignment operator
computer keyboard as you can see.
And these computers Sibiu you assignment operator computer spew.
So here this keyword actually refers to an instance that we are going to create from this computer class.
Right.
When I say these computer name refers to an instance of this class that actually has this computer in
an instance variable.
So that's why it is called instance variable right.
So this computer name is actually adding to the instance variable assignment operator computer name
refers to this argument.
Right.
So hopefully that makes sense.
And now this actually creates the getters and they get this that we need for these instance variables.
So again before the end in calibrates of this class and inside this class just right click here and
then we can generate and he can get it right.
And he had against select all these instance variables.
So just hold the shift key on your keyboard and select all these instance variables and then click on
OK.
So now as you can see here all these getters are actually the generators for us automatically by the
Android studio.
Right.
So we have actually get help for the computer name public screen.
Gates can actually see you.
So as you can see here the order is not actually important here.
So the first Gittel is for the computer Sibiu.
So publics can get computers is actually a method that is going to return the value of the compute computer
Sibiu instance variable.
And here we have public street get a computer name that is going to return the value of the computer
name public end gets computer power.
As you can see here returned computer power public integrates computer speed written computer speed
public interface computer ram written computer ram public street kids computer screen right hand computer
screen.
And finally we have this method public is three jet's computer keyboard written computer keyboard.
So this is our computer class right.
So let's go back to our main activity the job right here and now let's actually just declare some objects
here.
The first object that we need to declare here is actually firebase database and the name of our Optik
is going to be firebase database semi-colon.
And the second object is of type database reference and the name of this object is database reference.
Right.
So this Firebrace database here is going to actually help us to actually get the firebase instance.
So let me show you the other browser.
So as you can see here this is our web browser and this is actually a database instance right.
So now as you can see here we have this instance and we have this database reference that can actually
help us to find the reference.
And actually we can actually work on our references and we can add references and work on our database.
So let's go back to our Android studio.
So the first object is firebase database.
And the second object is database reference.
So here inside is uncreate Mefford Let's actually initialize these objects that we declared here in
line number 28 and 29.
So the first object is firebase database.
Inside this uncreate my feet I can say firebase database assignment operator.
And here I can say firebase database that gets instance semicolon.
In fact let's actually change the name of this variable which is of type firebase database.
So here inside this class as you can see in line number 28 we actually created this value right.
We declared this variable.
And we named it firebase database.
So let's actually just name it firebase database instance right.
It's more meaningful firebase database instance and inside is uncreate unfaith.
There's actually just type in firebase database instance.
So now I have to firebase database instance right by calling this method we get the firebase database
instance.
And now let's say actually initialize this database reference here.
So now here after this line of code I can't say databased or France assignment operator.
And then I need to refer to the name of this instance firebase database instance so Firebrace database
instance it get the reference as you can see here.
Choose this one with this argument which is of type string.
And now I need to provide an argument of types 3.
So inside Apprentice's just put two double quotes and you want to get to instance to computers category.
So here all you want to actually create reference to our computer.
The computers category so I want to create.
So let's go back.
Let's go to our web browser here.
So as you can see here when I say unable to actually just create a category here I can just click on
this child here and here I can say for example computers light computers and because I want to create
a category we do not actually provide a value for this value here.
Right.
So we just again click on these I tried here and now as you can see these computers is actually a category
that can contain other types.
Right.
So that's what you want to do with the code.
So let's go back to what Android studio when I actually just referred to this database reference here
I am actually just referring to this instance.
Right.
So this instance firebase database instance is has the inside has the database instance right.
These firebase database instance already has the database instance.
So what do I mean by database instance.
This means that we already have access to this instance.
As you can see here.
But now because I want to actually create a category by using Java codes as you can see here in line
number 58 I just referred to the name of this database reference so that we can actually just hold the
database reference inside this variable and then I put an assignment operator here and then I'll refer
to the name of this firebase database instance and then I want to actually create a reference to our
category and then after this we can actually add children to this category.
So firebase database instance that reference computers.
So this line of code here is like this one here as you can see we created a category computer.
And now this database defense has a reference to the computers category inside our database.
Not this one but this one.
So let's you delete this one here.
Let's go back to our Android studio and what.
Now I want to show you that how this works.
So here for example I can say database reference dots tied.
And now I can actually provide the child so the child could be for example key and he or dot set value
and the value could be for example value added with a semicolon at the end of my statement.
Right.
So now let's run our project and now let me show you the web browser and the emulator
so as you can see here now we have these computers category as you can see here.
And inside these computers tactically we have these key and value so that that's how you can actually
create a category by using your double quotes by you writing double quotes.
You can also create categories and children here.
So that's how you do it.
So now in line number six the list actually deletes this line of code here and now you know that we
have actually our reference to these computers category.
So if I had on my project nothing happens let's actually go back to our Web browser and see if we actually
did it this instance here this category.
As you can see here now that I am actually running this project as as you can see here nothing happens.
Why.
Because it in line number 58 inside and inside our Android studio.
You're saying that we are going to have a category that is actually computers but but because we haven't
still provided tights for this category the database is not going to show us.
So that for us because this chatter doesn't have children.
So first we need to provide the children and then we can see these computers category inside our database.
As you can see here.
But for now nothing just happens here.
So let's go back to what I understood you.
So now you know that this database of friends has a reference to the computers category.
So now.