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
/
Arrays and Lists (de)

Arrays and Lists (de)

Sep 22, 2017

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,
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
  • Programming in Processing (java)
    • Starting with Processing (en)
    • Variables (en)
    • Classes and Objects (en)
    • Events und Functions (en)
    • Writing our own Functions (en)
    • Random Numbers (en)
    • Conditionals (en)
    • Loops (en)
    • Nested Loops (en)
    • Coordinates (en)
    • Arrays and Lists (en)
      • Arrays and Lists (de)
    • SVG + Images (en)
    • Motion and Temporality
    • Gesture Interactions
    • Using bitmaps as modifiers
    • Vectors
    • Animation
    • Animation 2
    • Simple Collision Detection
    • Sound
    • Typography

{"serverDuration": 15, "requestCorrelationId": "7fa09571755d49499dae945f9b926a1b"}