Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
Confluence
For you

Programming
Results will update as you type.
  • Tiling and Repetition
  • Reactors
  • Programming Basics: Parametric and Generative Graphic Design 2016
  • Archive
  • High Scores
  • Artificial Neural Network
  • Alternatives to the Processing IDE
  • p5.js Programming
    • p5.js Introduction
    • p5.js Variables
    • p5.js Random Numbers
    • p5.js SVG + Images
    • p5.js WebGL
    • p5.js Classes and Objects
    • p5.js Events and Functions
    • p5.js Loops
    • p5.js Coordinates
    • P5js Nested Loops
    • p5.js Animation Exercise 1
    • p5.js Animation Exercise 2
    • p5.js Conditionals
    • p5.js Arrays and Lists
      • P5js Arrays and Lists (de)
    • p5.js Simple Collision Detection
    • p5.js Reactors
    • p5.js Tiling and Repetition
    • p5.js Vectors
    • p5.js Animation Solution with Objects
    • p5.js Easing
    • p5.js Perlin Noise
    • p5.js Particle System
    • p5.js Sound
    • p5j.s Typography
    • P5js Archive
  • Programming in Processing (java)

/
P5js Arrays and Lists (de)

P5js Arrays and Lists (de)

Jul 30, 2021

Arrays sind in Java Datenstrukturen welchen Tabellen darstellen. Damit kann mehrere Variablen des gleichen Typs zusammenfassen.

int[] zahlenArray;
 
zahlenArray = new int[10];
println(zahlenArray.length);
 
for(int i=0;i < zahlenArray.length;i++)
   zahlenArray[i] = i * 2;
 
println(zahlenArray);

Arrays kann man sich wie Schubladenstöcke vorstellen, sie Speichern in ihren Schubladen die Variablen. Der Schubladenstock hat einen bestimmen Typ und jede Schublade ist ein Speicher desselbigen. Die einzelnen Schubladen sind durch nummeriert und fangen bei 0 an. Die Grösse oder respektive die Länge ist in der Variable ‘length’ gespeichert. Arrays sind nicht dynamisch, sie können ihre Länge nicht zur Laufzeit ändern. Wenn man ein dynamische Array braucht, dann sollte man zu ‘ArrayList‘ greifen.

ArrayList<Integer> zahlenList;
 
zahlenList = new ArrayList<Integer>();
println(zahlenList.size());
 
for(int i=0;i < 10;i++)
   zahlenList.add(i * 2);
 
println(zahlenList);
 
zahlenList.add(100);
println(zahlenList.size());
println(zahlenList);
 
zahlenList.remove(0);
println(zahlenList.size());
println(zahlenList);
 
println(zahlenList.get(0));
, multiple selections available,
{"serverDuration": 13, "requestCorrelationId": "b15a3ed15b52473ebbdfb8d074e72dfe"}