# Question about Constructors in Child Classes

**URL:** <https://users.scala-lang.org/t/question-about-constructors-in-child-classes/10669>\
**Category:** Question\
**Created:** [March 30, 2025, 2:41pm UTC](https://users.scala-lang.org/t/question-about-constructors-in-child-classes/10669 "2025-03-30T14:41:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Taskeren](https://users.scala-lang.org/user_avatar/users.scala-lang.org/taskeren/32/3262_2.png) [@Taskeren](https://users.scala-lang.org/u/Taskeren)\
**Post date:** [March 30, 2025, 2:41pm UTC](https://users.scala-lang.org/t/question-about-constructors-in-child-classes/10669/1 "2025-03-30T14:41:59Z")

</div>

I’m currently facing a problem that I need to extend a class from Java, whose constructors are like `<init>#(Int)` and `<init>#(String)` for different usages.

I need to create both of them in my Scala child classes, but as far as I know, Scala only allows for 1 primary constructor that can call super, others are forced to call the primary constructor.

I don’t know if I misunderstand it or in Scala there is a better way to handle this situation?

---

<div class="post-metadata">

**Author:** ![BalmungSan](https://users.scala-lang.org/user_avatar/users.scala-lang.org/balmungsan/32/1700_2.png) [@BalmungSan](https://users.scala-lang.org/u/BalmungSan)\
**Post date:** [March 30, 2025, 2:47pm UTC](https://users.scala-lang.org/t/question-about-constructors-in-child-classes/10669/2 "2025-03-30T14:47:04Z")

</div>

AFAIK you are correct.  
Thus, I think the best thing you can do is have two classes, each one called the right constructor, and hide them behind a factory.

---

<div class="post-metadata">

**Author:** ![DmytroMitin](https://users.scala-lang.org/user_avatar/users.scala-lang.org/dmytromitin/32/1423_2.png) [@DmytroMitin](https://users.scala-lang.org/u/DmytroMitin)\
**Post date:** [March 30, 2025, 4:14pm UTC](https://users.scala-lang.org/t/question-about-constructors-in-child-classes/10669/3 "2025-03-30T16:14:41Z")

</div>

[In Scala, how can I subclass a Java class with multiple constructors?](https://stackoverflow.com/questions/3299776/in-scala-how-can-i-subclass-a-java-class-with-multiple-constructors/)

[Subclassing and overriding Java class with protected field access](https://stackoverflow.com/questions/79540491/subclassing-and-overriding-java-class-with-protected-field-access)

---

<div class="post-metadata">

**Author:** ![Taskeren](https://users.scala-lang.org/user_avatar/users.scala-lang.org/taskeren/32/3262_2.png) [@Taskeren](https://users.scala-lang.org/u/Taskeren)\
**Post date:** [March 31, 2025, 4:09am UTC](https://users.scala-lang.org/t/question-about-constructors-in-child-classes/10669/4 "2025-03-31T04:09:56Z")

</div>

Oh, I actually works. But this design it pretty weird imo.
