Saltar al reproductor
Saltar al contenido principal
Buscar
Iniciar sesión
Ver en pantalla completa
Me gusta
Añadir marcador
Compartir
Más
Añadir a la lista de reproducción
Denunciar
Modificador de paquete (default) en java || Taller 5
Ronald
Seguir
hace 5 semanas
En este video se explica el modificador de acceso default en java
Categoría
📚
Aprendizaje
Transcripción
Mostrar la transcripción completa del vídeo
00:00
Hello everyone, in this video we are going to talk about this FAO access modifier or package modifier.
00:08
This FAO access modifier has an access level that applies to members of the class
00:16
when no explicit access modifier is specified
00:23
That means that when we create a variable we are going to create a variable down here.
00:30
an integer variable called A
00:34
But we assign an access modifier to that variable. In this case, I want it to be public for the other classes.
00:44
then I write here PULL
00:45
and here we are defining a variable of integer type and that is a public access modifier
00:56
But what is the package or FAO access modifier?
01:02
is one that does not have an access modifier explicitly specified
01:09
In this case we have an example with this class called products
01:17
In this product class we have three attributes
01:21
one of type string, one of type double and one boolean
01:29
with its respective parameterized constructor to initialize the objects
01:35
initialize the, to initialize the attributes of this class
01:42
and a method that also has FAO access modifier
01:52
That is, it does not have an explicit access modifier if it is public, if it is private or if it is protected.
02:00
Well then as you can see the attributes and methods up to the constructor
02:10
are found with FAO access modifier, package
02:17
What are the advantages and disadvantages of having this package modifier or FAO?
02:27
Well, one of the first advantages is that it can be accessed from the same class.
02:34
from the same package
02:36
but the disadvantage is that it cannot be accessed from a subclass
02:42
not even outside the package
02:45
What does this mean?
02:47
that I can access these attributes and these methods
02:53
being in that same package where the class is
02:57
So if I believe myself
03:00
I have a package called company
03:06
Within that package is the products class
03:10
and another class called test
03:13
where the main method is
03:15
So here we can see that in product
03:21
We create a product object called corn
03:25
we create your instance
03:27
We initialize it as the product name corn
03:32
its price and its stock
03:34
but just as we can initialize it
03:38
we can access it directly
03:41
since we are in the same package
03:44
where that kind of product is located
03:47
and we can access it through class E
03:56
and we can display the information that we assigned here by accessing those variables
04:07
As you can see it shows us
04:10
the values we had assigned to it here directly
04:15
but if we comment on this line
04:18
What it will show us are the values that we passed to the constructor
04:24
so if we comment on them
04:27
once commented
04:32
we go back and execute
04:34
will not show us this anymore
04:36
but this
04:37
and here it is
04:39
if we go to another class
04:43
outside the package
04:46
we try to create
04:48
an instance
04:49
of the class
04:50
of the product class
04:52
As you can see
04:56
when trying to access
04:58
to class E
05:00
when trying to create an object
05:02
product
05:04
It marks an error for us
05:06
and why it marks us as an error
05:08
because
05:09
the builder
05:10
has access
05:12
from FAO
05:13
which means that
05:16
can only be accessed
05:18
from their own class
05:20
and within the same package
05:22
but outside the package
05:24
cannot be accessed
05:26
and within the same package
05:28
of the class
05:29
and inside the package
05:31
about the class
05:32
because
05:32
can be accessed
05:33
from their own class
Sé la primera persona en añadir un comentario
Añade tu comentario
Recomendada
5:10
|
Próximamente
Modificador de Acceso protected en Java || Taller 6
Ronald
hace 5 semanas
7:04
Sobre escritura de Métodos en Java || Taller 10
Ronald
hace 5 semanas
3:44
Uso de super en Java || Taller 9
Ronald
hace 5 semanas
5:47
Herencia Simple en Java || Taller 8
Ronald
hace 5 semanas
8:10
Modificador de Acceso public en Java || Taller 7
Ronald
hace 5 semanas
4:18
Modificador de acceso private en java || Taller 4
Ronald
hace 5 semanas
5:47
Modificador static en java || Taller 3
Ronald
hace 5 semanas
7:02
Uso de this en java || Taller 2
Ronald
hace 5 semanas
11:44
Constructores en java || Taller 1
Ronald
hace 5 semanas
0:51
Former Aide Claims She Was Asked to Make a ‘Hit List’ For Trump
Veuer
hace 2 años
1:08
Musk’s X Is ‘the Platform With the Largest Ratio of Misinformation or Disinformation’ Amongst All Social Media Platforms
Veuer
hace 2 años
4:50
59 companies that are changing the world: From Tesla to Chobani
Fortune
hace 2 años
0:46
3 Things to Know About Coco Gauff's Parents
People
hace 2 años
0:35
8 Things to Do in the Morning to Improve Productivity
Martha Stewart Living
hace 2 años
2:11
Why You Should Remember Aretha Franklin
Goalcast
hace 2 años
1:18
USC vs. Colorado: Can Caleb Williams Earn a New Heisman Moment?
SportsGrid
hace 2 años
1:04
Vic Mensa Reveals Celebrity Crush, Biggest Dating Pet Peeve & More on Speed Dating | Billboard News
Billboard
hace 2 años
1:09
Hollywood Writers Reach ‘Tentative Agreement’ With Studios After 146 Day Strike
Veuer
hace 2 años
1:26
Love is Blind stars admit they're burnt out from social media
Fortune
hace 2 años
2:01
NHA Customers in Limbo as Company Faces Potential Merger
SportsGrid
hace 2 años
2:55
Vanilla Ice Explains How the 90’s Shaped America
FACTZ
hace 2 años
0:36
Amazon’ Prime Video Will Show Commercials Starting Next Year
Veuer
hace 2 años
11:13
Pokimane Answers The Web's Most Searched Questions
WIRED
hace 2 años
4:16
BREAKING NEWS: Matt Gaetz Tells House Committee: 'I'm Not Going To Vote For A Continuing Resolution'
Forbes Breaking News
hace 2 años
1:00
What's Popular on Uber Eats?
Stringr
hace 2 años
Sé la primera persona en añadir un comentario