So now in order to actually create another package just click on this as artsy folder and then click
on File New and then click on package.
So for the package name we need our reverse domain here.
So that statement here com that your name dot custom package.
OK.
And then click on finish.
So as you can see here our package is now created.
So now I want to create another class and put that class inside the spy cage.
So just click on this package and then click on File Neal and then click on class.
So for the class name just type in here custom class.
OK.
And for the modifiers choose public.
And here check the sequence here.
Public is static void main method and then click on finish.
So as you can see here our class is now created.
So now I want to actually create an object from the start class.
OK.
So first I need to refer to the name of my class dog and then I need to give my object a name.
For example dog 1 and then I put an assignment operator here and then I use this vote here new.
And then I refer to the name of my class dog and I actually put a pair of round brackets after my class
name.
OK.
And then I need to put in a semicolon at the end of my statement.
So as you can see here it's now showing us an error.
OK so let's hover over the error area and see what's the error.
So as you can see here dog can not be resolved to a type and this means this class doesn't recognize
this dog that Java class.
OK.
It doesn't recognize this class.
OK so what's the problem.
The problem is this custom class that Java is inside this package.
OK.
And this class is inside this package and this class can not refer to the name of its class in order
to create objects.
In other words this class doesn't recognize this class.
Ok inside this package.
So in order to actually allow this class this custom class that Jarba to create objects from this dog
Java class we need to import the address of this dog Java class or the address of this package to this
custom class that Java.
In order to actually access those classes.
Ok so if you for example import the address of this package inside this class we can actually use all
of the classes inside this package.
OK.
But if you only actually import the address of this class to this package you can only actually use
this class inside your custom class that job.
OK so I prefer for now to actually import the address of this package to this class.
Ok inside your custom class that Jobab.
And before the class creation type in here.
Import.
OK.
Come dot Mortaza
getters and setters.
So as you can see here we managed to successfully import the address of this package to our custom class
that Java.
OK this class is inside of this package.
OK.
Can't that mortiser that custom package.
OK.
And now as you can see the error is gone.
OK so we can actually access all of the classes that is inside of this package.
OK.
So now I want to actually access the speed instance variable of these thugs one object.
OK.
And then I want to output that value to the console.
So I just need to type in here a system that out that Pantalone and that inside the prentices I need
to refer to the name of my object Doug.
One that's get speed and then I need to put in a semi-colon at the end of my statement.
So as you can see here it's now showing us an error.
So let's actually hover over the error area and see what's the error the Mefford get speed from the
type.
Doug is not visible.
So as you can see here we cannot refer to the get speed method of this object from this class.
OK so what's the problem.
So let's go inside.
Dog the java file.
As you can see here in this class this method uses the package as it's access modifying the access modifier
of the Smurfette is package and package means that this method is only visible to the whole package.
And it means that this method is only visible to the classes of this package not classes in another
package.
So in order to solve this problem we need to use another access modifier public so public means visible
to the whole world.
OK.
And as you can see here inside the custom cluster Java now the error is gone.
OK.
And I managed to successfully access this get speed method and now I can actually output that value
to the console.
So now if I want to run the code inside this method inside the main effort of this custom class I just
need to right click on this class and then click on run as job application.
So as you can see here disvalue is the value of this speed instance variable of this object.
OK.
And the value of this bit in this variable is 70.
OK.
So that's it that's how you can actually access the instance variables of another class inside another
package.
OK you can see here.
This is public.
Or create a public access modifier means visible to the whole world.
And when you use the public access modifier on MFL or on a variable that Mefford or valuable is going
to be visible to all the java files of that project.
OK so the next access modifier which is very important is private.
So remember that inside the mind that Java class I could successfully access the instance variables
of this my first talk object directly.
OK.
And this is the code that proves that I can't directly access the speed instance variable directly.
OK so now let me actually delete this line of code here.
In order not to allow any other classes other than this thug class to access its instance variables
directly we need to use an ORDER access modifier which is private.
So now let's go inside the main Java class.
So as you can see here it's now showing us an error.
OK.
So as you can see here this class doesn't recognize this speed instance variable no longer.
OK so we cannot actually access this speed instance valuable directly because we used these private
access modifier and this access modifier private means that this variable is only visible inside of
this class.
Ok inside of this Java.
OK.
And we cannot use this instance variable from any places other than this class.
Ok this instance valuable is private.
So in order to actually access the value of the speed instance variable we must use this get help method.
OK great speed.
So now if I want to actually correct this error I just need to delete this speed instance variable and
then I need to refer to the name of my get speed Meffert.
So now I can actually access the value of that speed instance variable.
So now if I get on my project as you can see the value of this sweet instance variable is 70.
OK so that's how you can actually use the access modifiers in your codes.
OK we've got another access modifier in Java which I'll tell you more about in the next tutorials.
OK.
Now I want to actually tell you another important point about running our Java projects.
Ok so now if I actually write you click on these get hairs and set her project as you can see here and
then click on runners and then click on Java application.
So as you can see here it's now showing us this window here.
OK.
And here it says matching items main dash cam that Mortaza dot getters and setters workspace matches
custom class dash cam that mortars or that custom package.
So as you can see here because we've got two main methods inside of these classes the main class and
the custom class it's now asking us to determine which one of the classes we want to run.
So if I actually click on this option here it's going to actually run the codes inside the main method
that is inside the main class.
OK.
As you can see here.
But if we actually choose this option here it's going to actually run the code inside the main method.
Inside the custom class that job.
OK.
So here I can actually choose which one of these classes I want to run.
OK.
So if I actually choose this option and then click on OK it's going to actually execute the code inside
of the main effect of this main class.
OK.