# Print class variables

**URL:** <https://discourse.processing.org/t/print-class-variables/8142>\
**Category:** Beginners\
**Created:** [February 5, 2019, 8:37pm UTC](https://discourse.processing.org/t/print-class-variables/8142 "2019-02-05T20:37:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f42ter](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/f42ter/32/16793_2.png) [@f42ter](https://discourse.processing.org/u/f42ter)\
**Post date:** [February 5, 2019, 8:37pm UTC](https://discourse.processing.org/t/print-class-variables/8142/1 "2019-02-05T20:37:35Z")

</div>

Sorry to bother you again but I’m working on a class with a large number of variables (in C I would implement this as a struct). For debugging purposes I want to print (loop) over all variables inside this class. Unfortunatly I have no clue how to implement this.

Put me in the nasty boy room in case this is a stupid question.

---

<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:** [February 5, 2019, 9:01pm UTC](https://discourse.processing.org/t/print-class-variables/8142/2 "2019-02-05T21:01:55Z")

</div>

A class needs to [`@Override`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Override.html) the [**toString()**](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#toString()) method, so it can return a String w/ the current value of its fields. ☕

Here’s a link w/ an example for it: 🔗

- [Forum.Processing.org/two/discussion/25986/how-can-i-replace-pvector-tostring#Item\_7](http://Forum.Processing.org/two/discussion/25986/how-can-i-replace-pvector-tostring#Item_7)
