Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Variables also have a lifetime. The computer manages the storage of variables, and when the life span is over, the memory is released again (Garbage-Collector). The range (Scope) in which a variable is accessible or active is defined by brackets ({}) (see also classes and functions). Variables that are at the top level are called global variables as they are accessible all over the program. Variables declared within brackets are local variables. If a local variable has the same name as a global variable, the local variable overrides it within its scope.


Code Block
// variablen deklarationDeclaration 
int x1 = 15;
float valF = 0.323;
boolean bFlag = false;
String message = "hallo 1";
char character = 'g';
 
String msg1 = new String("hallo 2");
 
println(x1);
println(valF);
println(bFlag);
println(message);
println(character);
println(msg1);

...

Code Block
int length1 = 150;
int length2 = 200;
 
size(300,300); // define window size fenstergrosse
background(0); // define background colour
stroke(255,255,255); // define line colour
 
line(100,10,100,length1); // draw a line 
line(150,10,150,length2);
line(200,10,200,250);
 
fill(0,0,0); // fill colour
strokeWeight(5); // line thickness 
ellipse(100,length1,50,50); // draw an ellipse
ellipse(150,length2,50,50); // draw an ellipse
noFill(); // turn off fill
ellipse(200,250,50,50); // draw an ellipse

...