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

Name

. (dot)

Examples
// Declare and construct two objects (h1 and h2) of the class HLine
HLine h1 = new HLine(20, 1.0);
HLine h2 = new HLine(50, 5.0);

void setup() {
  size(200, 200);
}

void draw() {
  if (h2.speed > 1.0) {  // Dot syntax can be used to get a value
    h2.speed -= 0.01;    // or set a value.
  }
  h1.update();  // Calls the h1 object's update() function
  h2.update();  // Calls the h2 object's update() function
}

class HLine {  // Class definition
  float ypos, speed;  // Data
  HLine (float y, float s) {  // Object constructor
    ypos = y;
    speed = s;
  }
  void update() {  // Update method
    ypos += speed;
    if (ypos > width) {
      ypos = 0;
    }
    line(0, ypos, width, ypos);
  }
}
Description Provides access to an object's methods and data. An object is one instance of a class and may contain both methods (object functions) and data (object variables and constants), as specified in the class definition. The dot operator directs the program to the information encapsulated within an object.
Syntax
object.method()
object.data
Parameters
object the object to be accessed
method() a method encapsulated in the object
data a variable or constant encapsulated in the object
RelatedObject
Updated on January 21, 2019 10:05:16am EST

Creative Commons License