How to use Multiple Constructors in a Kotlin Class

Sdílet
Vložit
  • čas přidán 8. 09. 2024
  • In this lesson, you'll learn how to create a class with multiple constructors.
    Watch the entire FREE Kotlin Programming course here: • How to Install the Int...

Komentáře • 6

  • @swaminathbera6407
    @swaminathbera6407 Před 2 lety +2

    Clear

  • @aishwaryapravatnalini9301

    Wow... this is amazing...thank you so much for this thorough and detailed video , it provided me with a lot of clarity and deep insights into constructors!

  • @peshutanpavri1599
    @peshutanpavri1599 Před 2 lety +1

    Great tutorial, but I don't like how Kotlin have designed this, this means, there can't be any proper constructor overloading, if we have to call the "primary constructor", this is one aspect that I think is far better in Java.
    What if we don't want to have those default values? What if we want one constructor that takes no arguments? What would be the best workaround for this?

  • @juancho31
    @juancho31 Před 2 lety

    Thank you so much, Donn! but what happens if the main constructor has only one param and I need to add another constructor which has more params? Thanks again

  • @tree12341
    @tree12341 Před 3 lety

    Hello this is a great video! How would you do this for a child class where the parent has multiple constructors, but the child also has multiple constructors. How would a child be able to call different super() methods depending on the constructor?