4
good , can anyone tell me what this does ?
public Tempo (){
this(0,0,0);
}
public Tempo (int h){
this(h,0,0);
}
public Tempo ( int h,int m){
this (h,m,0);
}
public Tempo (int h,int m , int s){
SetTime(h,m,s);
}
4
good , can anyone tell me what this does ?
public Tempo (){
this(0,0,0);
}
public Tempo (int h){
this(h,0,0);
}
public Tempo ( int h,int m){
this (h,m,0);
}
public Tempo (int h,int m , int s){
SetTime(h,m,s);
}
5
The construction this
inside the constructor serves to call another constructor.
That is to say this(0,0,0);
will call the builder
public Tempo (int h,int m , int s){
SetTime(h,m,s);
}
It cannot be used in a conventional method and must be the first instruction within the constructor, that is, if you want to use it. It’s just a way to maintain the object initialization logic in only one of the constructors.
Browser other questions tagged java
You are not signed in. Login or sign up in order to post.
Calling the constructor means that it will execute the contents of that constructor ,ie the setTime method ?
– Pedro Gouveia
It’s perfect, Bruno, perfect. Just to complement, what will define which constructor will be called, are the types and the amount of parameters passed in this method().
– Rafael Coelho
@Pedrogouveia Yes Peter, he will call the
setTime
– Bruno Costa