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
Constructores en java || Taller 1
Ronald
Seguir
hace 5 semanas
#java
#programacion
#dev
#constructor
En este video se explica que es un constructor con ejemplos.
¿Que es un constructor?
Constructores en java
#java #programacion #dev #constructor
Categoría
📚
Aprendizaje
Transcripción
Mostrar la transcripción completa del vídeo
00:00
Hello everyone, welcome to this new video.
00:02
which will deal with constructor methods
00:06
let's get started
00:08
which is a constructor method
00:09
A constructor method is one that is executed when a method is created.
00:14
an object of this class
00:16
In this case we have a class called book
00:20
which contains three attributes
00:24
that those three attributes are two of type string
00:28
script and one
00:30
of type
00:32
integer primitive data
00:34
have
00:35
as the first builder
00:37
a default constructor
00:40
This builder
00:41
It is used for
00:44
initialize the variables
00:45
every time
00:48
that an instance of this class is created
00:50
in this case
00:52
the class is called book
00:54
so
00:56
This method what is done
00:58
that once an instance of this class is created
01:02
he initializes
01:04
the attributes of this class
01:07
this
01:10
we can see that it assigns it
01:12
a stranger
01:14
by title and author
01:16
which are two of the
01:18
two of the attributes
01:20
string type
01:21
from the book class
01:23
and we have
01:24
that initializes
01:26
the page number
01:29
initializes it by assigning it the value of zero
01:32
as we can see
01:34
Here we have
01:35
another builder
01:37
parameterized call
01:39
which receives
01:41
parameters to be able to initialize the object
01:45
when creating an instance
01:47
of this kind book
01:48
now about us
01:50
instantiate the book class
01:52
to create an object
01:54
then
01:57
This builder
01:59
is going to ask
02:00
three parameters
02:01
two types of script
02:04
and one
02:07
of integer primitive data
02:09
what is the page number
02:11
what does that mean
02:13
that every time you want to create an instance
02:16
from the book class
02:18
the builder
02:20
will tell you what you need
02:24
the three object parameters
02:28
which are the three instances
02:30
from the book class
02:32
so
02:33
so that
02:35
the reserved word is used
02:38
dis
02:38
Well
02:39
this word dis
02:41
is used to refer to
02:43
in the current instance
02:44
of
02:45
the object
02:46
what does it mean
02:47
Here we have
02:50
two variables
02:51
calls
02:52
qualification
02:53
TRUE
02:54
so
02:56
if one removes
02:56
This dis
02:58
it would look like this
02:59
qualification
03:00
is equal to title
03:01
I mean
03:02
what is
03:03
in the variable
03:05
qualification
03:05
will be assigned to you
03:07
to the other variable
03:08
qualification
03:09
but
03:10
so
03:11
as
03:11
Java
03:12
I mean
03:12
this
03:14
difference
03:15
to
03:16
this
03:17
where to assign it
03:18
that variable
03:18
because the two
03:19
they are called
03:20
equal
03:21
so
03:22
which
03:22
makes the word
03:24
dis
03:24
dis
03:26
in Spanish
03:27
wants to refer
03:28
like what
03:29
this
03:29
this case
03:31
means
03:31
that
03:32
this
03:33
qualification
03:34
I mean
03:34
This variable
03:35
will save
03:36
what is going to be received
03:38
by
03:38
parameter
03:40
this
03:41
qualification
03:43
will be saved
03:45
in
03:45
will be saved
03:51
in it
03:51
attribute
03:52
qualification
03:53
of the class
03:54
for that
03:56
is used
03:57
dis
03:58
and how
04:00
can see
04:01
here
04:01
have
04:03
a
04:05
a method
04:07
called
04:08
display data
04:09
that does not receive
04:11
none
04:11
parameter
04:11
this
04:13
This method
04:15
is of type
04:16
public
04:17
and
04:19
returns
04:19
void
04:20
of type
04:21
return
04:22
void
04:22
that
04:23
void
04:23
means
04:24
that
04:24
does not return
04:26
nothing
04:26
I mean
04:27
void
04:28
in Spanish
04:28
means
04:29
empty
04:30
so
04:31
This method
04:32
has
04:33
a
04:33
system
04:34
spot
04:34
spot
04:35
print
04:35
this
04:37
this
04:37
I mean
04:38
will show
04:39
by
04:39
console
04:40
is going to print
04:41
by console
04:42
what this
04:44
inside
04:44
of these
04:44
parenthesis
04:45
and in this
04:46
case
04:46
will show
04:47
qualification
04:48
concatenated
04:50
dis
04:51
spot
04:51
qualification
04:52
what does he want
04:52
say
04:53
when
04:54
this
04:54
dis
04:54
spot
04:54
qualification
04:55
will show
04:56
is what
04:57
contains
04:58
the
05:00
variable
05:01
qualification
05:02
but
05:03
of the
05:04
of the
05:06
attribute
05:06
of the
05:06
class
05:07
and by
05:09
here
05:09
have
05:10
other
05:11
other
05:13
method
05:13
that returns
05:15
of type
05:16
public
05:17
that returns
05:17
a
05:17
string
05:18
what are you doing
05:20
this
05:20
method
05:21
well
05:22
this
05:22
method
05:23
returns
05:24
returns
05:25
a
05:25
string
05:26
chain
05:27
which
05:29
us
05:29
indicates
05:30
he
05:31
state
05:31
of the
05:32
object
05:32
in that
05:33
instant
05:34
to the
05:35
call
05:36
to this
05:37
method
05:38
also
05:40
have
05:41
a
05:41
account
05:42
a
05:43
class
05:43
call
05:44
account
05:44
banking
05:45
where
05:46
have
05:46
in this
05:47
case
05:48
three
05:48
guys
05:49
of
05:49
builders
05:50
and to this
05:52
he is
05:52
we call
05:53
he is
05:54
calls
05:54
overload
05:56
of
05:57
builders
05:57
what does he want
05:58
say this
05:59
what are they
06:00
several
06:00
builders
06:01
with the same
06:02
name
06:03
but
06:04
with
06:04
different
06:05
parameters
06:05
with
06:07
different
06:07
parameters
06:09
as
06:12
they can
06:13
see
06:13
this
06:13
have
06:14
a
06:15
method
06:15
default
06:16
have
06:17
a
06:18
method
06:18
that
06:19
a
06:22
method
06:22
parameterized
06:23
with
06:25
two
06:25
parameters
06:25
and how
06:27
they can
06:27
see
06:27
have
06:28
this
06:29
with
06:30
three
06:30
parameters
06:31
as
06:33
they can
06:33
see
06:33
here
06:34
this
06:35
have
06:35
this
06:37
line
06:37
which
06:38
wants
06:38
explain
06:39
the thing is
06:40
this
06:40
calling
06:40
to the
06:42
builder
06:42
that
06:44
has
06:44
nothing else
06:45
two
06:45
parameters
06:46
Well
06:47
and also
06:48
have
06:49
a
06:49
method
06:49
also
06:50
called
06:51
you
06:51
sprint
06:52
here
06:52
by
06:55
here
06:55
can
06:56
see
06:56
by
07:04
here
07:04
can
07:04
see
07:05
a
07:05
class
07:06
of
07:06
student
07:07
a
07:09
class
07:09
student
07:10
with
07:11
his
07:11
variable
07:15
have
07:17
a
07:17
class
07:17
call
07:18
also
07:18
student
07:19
and
07:20
have
07:21
a
07:21
class
07:21
main
07:22
where
07:23
come on
07:23
approve
07:24
and
07:28
have
07:29
a
07:29
class
07:29
main
07:29
where
07:30
this
07:32
where
07:33
can
07:33
see
07:34
here
07:34
where
07:34
we create
07:35
a
07:36
object
07:36
a
07:38
object
07:38
book
07:38
called
07:40
lb
07:42
where
07:44
we passed it on
07:45
these
07:45
parameters
07:46
to the
07:46
builder
07:46
so that
07:47
initialize
07:48
the
07:49
attributes
07:49
of
07:50
the
07:50
instance
07:51
here
07:53
also
07:54
we create
07:54
also
07:55
this
07:57
other
07:58
object
07:58
student
07:59
and another
08:00
object
08:01
account
08:01
banking
08:02
we send you
08:03
to
08:05
this
08:06
to this
08:07
instance
08:08
nothing else
08:08
we send you
08:09
three
08:10
three
08:12
parameters
08:14
to this
08:14
we do not send him
08:15
nothing
08:16
that's it
08:18
we send you
08:18
nothing else
08:19
two
08:19
what do you want
08:20
say
08:21
this
08:21
Yeah
08:22
to
08:23
this
08:23
Yeah
08:25
to this
08:26
class
08:26
this
08:27
Well
08:32
this
08:33
and once
08:35
instantiated
08:36
the
08:39
classes
08:39
once
08:41
created
08:41
the
08:41
objects
08:42
can
08:44
this
08:46
we import
08:47
the class
08:48
scan
08:48
this
08:49
class
08:50
scan
08:50
which
08:51
us
08:51
allows
08:51
is
08:52
receive
08:53
parameters
08:54
by
08:55
console
08:56
by the
08:57
terminal
08:58
so
08:59
as they can
09:01
see
09:01
here
09:02
can
09:03
say
09:03
system.2.prey
09:05
enter the name
09:06
of the student
09:07
so
09:09
that
09:10
which
09:11
let's write
09:11
by console
09:12
with the
09:14
method
09:14
with the
09:15
object
09:16
with the
09:17
object
09:18
created
09:18
of
09:19
rest.netline
09:21
which
09:22
we are
09:23
indicating
09:24
that
09:24
we are
09:26
expecting
09:27
by console
09:28
this
09:30
we are waiting
09:33
by console
09:34
a
09:34
string
09:35
and this
09:36
will save it
09:37
in a
09:38
string
09:38
call
09:39
name
09:39
and so on
09:40
successively
09:41
after
09:43
that
09:44
all that
09:44
is given
09:45
after
09:46
to have
09:47
written
09:47
all the
09:47
parameters
09:48
is created
09:49
a
09:50
new
09:50
object
09:50
student
09:51
where
09:52
he is
09:53
send
09:53
by parameter
09:54
he
09:55
worth
09:56
of the
09:58
variables
09:58
that
09:59
we had
09:59
created
10:00
that
10:00
we ask
10:00
by console
10:02
and
10:04
that
10:04
once
10:05
that is
10:05
keep
10:06
they are
10:06
we send
10:07
to the
10:07
builder
10:11
and
10:11
which
10:12
he's leaving
10:12
to
10:12
create
10:13
a
10:15
object
10:15
student
10:16
with
10:17
the
10:17
with
10:19
the
10:19
data
10:19
writings
10:20
by
10:20
console
10:20
and
10:22
here
10:22
can
10:23
print
10:23
the
10:23
details
10:24
of the
10:24
objects
10:25
with
10:25
he
10:26
method
10:26
screen
10:27
so
10:28
let's execute
10:29
this
10:29
to see
10:30
here
10:32
we put
10:32
a
10:32
name
10:33
and
10:43
as
10:43
they can
10:44
see
10:44
us
10:46
print
10:46
in this
10:48
case
10:48
he
10:49
state
10:49
of
10:49
this
10:50
object
10:50
here
10:52
in it
10:54
case
10:54
of
10:55
student
10:55
as
10:56
they can
10:56
see
10:56
here
10:57
No
10:57
we had
10:58
mandate
10:58
none
10:59
parameter
11:02
this wants
11:03
say
11:03
that
11:04
the
11:04
initializes
11:05
default
11:06
so
11:07
to no
11:09
initialize
11:10
a
11:10
screen
11:10
that
11:11
he
11:14
worth
11:15
of a
11:15
screen
11:15
default
11:16
is
11:16
null
11:17
and
11:18
of a
11:19
whole
11:19
is
11:19
zero
11:20
that's why
11:20
the thing is
11:20
here
11:21
No
11:21
sample
11:21
he
11:21
state
11:22
of the
11:24
object
11:24
but
11:24
No
11:25
sample
11:25
that
11:25
say
11:26
here
11:27
can
11:27
see
11:28
he
11:28
state
11:28
of
11:29
account
11:29
banking
11:30
that
11:30
was
11:31
the
11:32
parameters
11:32
that he
11:32
we send
11:33
over here
11:33
and
11:34
he
11:35
of
11:35
student
11:35
that
11:35
were
11:36
the
11:36
that
11:37
you
11:37
we send
11:37
by
11:38
console
11:39
and
11:41
So
11:41
ends
11:42
this
11:42
video
Sé la primera persona en añadir un comentario
Añade tu comentario
Recomendada
7:02
|
Próximamente
Uso de this en java || Taller 2
Ronald
hace 5 semanas
5:47
Modificador static en java || Taller 3
Ronald
hace 5 semanas
5:29
Modificador de paquete (default) en java || Taller 5
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
5:10
Modificador de Acceso protected en Java || Taller 6
Ronald
hace 5 semanas
4:18
Modificador de acceso private en java || Taller 4
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