This reference is for Processing 2.0+. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

extends

Examples
DrawDot dd1 = new DrawDot(50, 80);

void setup() { 
  size(200, 200);
} 
 
void draw() {
  dd1.display();
} 
 
class Dot { 
  int xpos, ypos;
} 

class DrawDot extends Dot {
  DrawDot(int x, int y) {
    xpos = x;
    ypos = y;
  }
  void display() {
    ellipse(xpos, ypos, 200, 200);
  }
}
Description Allows a new class to inherit the methods and data fields (variables and constants) from an existing class. In code, state the name of the new class, followed by the keyword extends and the name of the base class. The concept of inheritance is one of the fundamental principles of object oriented programming.

Note that in Java, and therefore also Processing, you cannot extend a class more than once. Instead, see implements.
Relatedclass
super
implements
Updated on March 27, 2014 07:26:11pm EDT

Creative Commons License