# Using class-wide methods in non-static classes

**URL:** <https://discourse.processing.org/t/using-class-wide-methods-in-non-static-classes/1677>\
**Category:** Coding Questions\
**Created:** [July 11, 2018, 1:53am UTC](https://discourse.processing.org/t/using-class-wide-methods-in-non-static-classes/1677 "2018-07-11T01:53:54Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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 11, 2018, 12:03pm UTC](https://discourse.processing.org/t/using-class-wide-methods-in-non-static-classes/1677/4 "2018-07-11T12:03:12Z")

</div>

Nice step-by-step @kfrajer. However, we can exceptionally have `static` fields inside inner classes as long as they’re `final` & either primitive or String; b/c in this case, they become compile-time constants: 😀

```auto
void setup() {
  final AutoCar car = new AutoCar();
  println("Planet:", car); // Planet: MARS
  exit();
}

class AutoCar {
  static final String PLANET = "MARS"; // Compile-time constant

  @Override String toString() {
    return PLANET;
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/using-class-wide-methods-in-non-static-classes/1677)._
