# Can a class method return the current instance of its class?

**URL:** <https://discourse.processing.org/t/can-a-class-method-return-the-current-instance-of-its-class/12690>\
**Category:** Coding Questions\
**Created:** [July 12, 2019, 8:32pm UTC](https://discourse.processing.org/t/can-a-class-method-return-the-current-instance-of-its-class/12690 "2019-07-12T20:32:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 12, 2019, 8:43pm UTC](https://discourse.processing.org/t/can-a-class-method-return-the-current-instance-of-its-class/12690/2 "2019-07-12T20:43:13Z")

</div>

> [@ddownn](#):
>
> , I was just hoping for a shortcut to avoid having to call a constructor.

You can use **clone()** in place of `new`: 👾

> [@Problema con Class, extend y herencia](https://discourse.processing.org/t/problema-con-class-extend-y-herencia/11204/4):
>
> I didn’t need to translate anything, nor use Google Translate. wink Like I had already explained, you’re gonna need to implement clone() in your own class, rather than relying on the [new operator](https://processing.org/reference/new.html): So instead of: Ball hijo() { return new Ball(); } Go w/ something like this: Ball hijo() { return clone(); } @Override Ball clone() { try { final Ball hijo = (Ball) super.clone(); hijo.location = location.get(); return hijo; } catch (final CloneNotSupportedException e) {…

---

_[View the full topic](https://discourse.processing.org/t/can-a-class-method-return-the-current-instance-of-its-class/12690)._
