Very good explanation but the example could have been better. The specific chains chosen make it hard to understand the concept. Why would a constructor that takes a year assume the team names? Something like "Home Team", "Away Team" would make it more clear what is going on, and would prevent the internal monologue of "it is just an example" that detracts from an otherwise great explanation.
I like your explanation. But to my opinion you make a mistake in your example. See 3:24. You have to use the default values twice. And in the all-args constructor you first call the default and set the values to the default and directly pass the arguments. That does not make sense. I think this should be the correct way - default calls one-args which in turn calls all-args constructor public FootballGame() { this(2011) } public FootballGame(int year) { this(year, "Arizona", "Denver") } public FootballGame(int year, String homeTeam, String awayTeam) { this.year = year; this.homeTeam = homeTeam; this.awayTeam = awayTeam; }
Amazing explanation
Great tutorial, love the graphics!
exactly what i needed ty
I'm super gay and hate football but it was still an amazing explanation, thanks.
You made my day mate 😂
Will the code compile if you are not referring to this.hometeam in your second constructor because they have the same name ?
Why we use constructor chaining in java
Good explanation! :)
what if the constructor doesn't take any argument?
Very good explanation but the example could have been better. The specific chains chosen make it hard to understand the concept. Why would a constructor that takes a year assume the team names? Something like "Home Team", "Away Team" would make it more clear what is going on, and would prevent the internal monologue of "it is just an example" that detracts from an otherwise great explanation.
I like your explanation. But to my opinion you make a mistake in your example. See 3:24. You have to use the default values twice. And in the all-args constructor you first call the default and set the values to the default and directly pass the arguments. That does not make sense. I think this should be the correct way - default calls one-args which in turn calls all-args constructor
public FootballGame() {
this(2011)
}
public FootballGame(int year) {
this(year, "Arizona", "Denver")
}
public FootballGame(int year, String homeTeam, String awayTeam) {
this.year = year;
this.homeTeam = homeTeam;
this.awayTeam = awayTeam;
}
ha
nice post more videos
String comment = "I'm more confused about constructor chaining than ever before, thanks for nothing!";