Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 674 Bytes

File metadata and controls

26 lines (18 loc) · 674 Bytes

Instance Methods

In addition to having fields, classes can also have their own method definitions.

These look the same as the method definitions you've seen so far, they are just put within a class definition.1

class Muppet {
    String name;

    void freakOut() {
        IO.println("**ANGRY KERMIT NOISES**")
    }
}

We call these instance methods because you need an instance of the class in order to call the method.

Footnotes

  1. If you haven't seen the muppets this might go over your head, but Kermit randomly gets really mad.