Java Constructor Chaining - 034

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ย. 2024
  • In this tutorial, we are looking at Java constructor chaining. Constructor chaining is chaining our constructors together, and calling each one in order before returning a created instance.

    Like the video? Don't forget to subscribe! ➜ www.deegeu.com/...

    Keep up to date with the newsletter! ➜ www.deegeu.com/...
    Transcript and code: www.deegeu.com/...
    Concepts: Java, classes, java constructor chaining, constructors
    Social Links: Don't hesitate to contact me if you have any further questions.
    WEBSITE : dj@deegeu.com
    TWITTER : / deegeucom
    FACEBOOK: / deegeu.programming.tut...
    GOOGLE+ : google.com/+Dee...
    About Me: www.deegeu.com/...
    Related Videos:
    Hide your class details with Java Access Modifiers - 027
    • Hide your class detail...
    Free Java Course Online
    • What important Java Te...
    Media credits: All images are owned by DJ Spiess unless listed below:
    Brick Background
    pixabay.com/
    Music
    Disco Lounge by Kevin MacLeod is licensed under a Creative Commons Attribution license (creativecommon...)
    Source: incompetech.com...
    Artist: incompetech.com/

ความคิดเห็น • 14

  • @sankalparora9374
    @sankalparora9374 3 ปีที่แล้ว +1

    Amazing explanation

  • @Zotijdvooreenpauze
    @Zotijdvooreenpauze 7 ปีที่แล้ว +3

    Great tutorial, love the graphics!

  • @joelvilleneuve7037
    @joelvilleneuve7037 4 ปีที่แล้ว

    exactly what i needed ty

  • @bennyburwell3102
    @bennyburwell3102 7 ปีที่แล้ว +17

    I'm super gay and hate football but it was still an amazing explanation, thanks.

    • @AlfeYT
      @AlfeYT 3 ปีที่แล้ว

      You made my day mate 😂

  • @piotrkaminski2445
    @piotrkaminski2445 6 ปีที่แล้ว

    Good explanation! :)

  • @h0rban
    @h0rban 6 ปีที่แล้ว

    Will the code compile if you are not referring to this.hometeam in your second constructor because they have the same name ?

  • @lokeshloki8795
    @lokeshloki8795 5 ปีที่แล้ว

    Why we use constructor chaining in java

  • @insmallportions
    @insmallportions 2 ปีที่แล้ว

    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.

  • @zedjurk
    @zedjurk 5 ปีที่แล้ว +1

    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;
    }

  • @maazahmedpoke
    @maazahmedpoke 5 ปีที่แล้ว

    what if the constructor doesn't take any argument?

  • @vinayTshetty
    @vinayTshetty 8 ปีที่แล้ว +1

    nice post more videos

  • @DanielADickey
    @DanielADickey 5 ปีที่แล้ว +3

    String comment = "I'm more confused about constructor chaining than ever before, thanks for nothing!";

  • @nurbayarahim5915
    @nurbayarahim5915 8 ปีที่แล้ว +1

    ha