GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Karteikarten

Arrays

Tony Meman Programming Englisch 11 Karten

Karten in diesem Stapel (11)

  1. 1Array- ordered list of values
    - a particular value is referenced using 'array name [ ]'
  2. 2Array Elements- store multiple values of the same type
    - can be primitive type or object reference
    -
  3. 3Declaring Arrays- eg. int [ ] variablename = new int [10]
    - this example sets the size of the array at 10 integers
    - eg: double[ ] prices = new double[500];
    - eg: boolean[] flags;
    flags = new boolean[20];
    - eg: char[ ] codes = new char[1750];
  4. 4Using Arrays- iterator version of the for loop can be used when processing array elements:
    for (int variablename: scores)
    System.out.println (variablename);
  5. 5Bounds Checking- once created, array size is fixed
    - java will recognise if a element is outside of array index and prints 'ArrayIndexOutOfBoundsException'
  6. 6Bounds Checking (cont.)- every array has a public constant called 'length'
    - referenced: variablename.length
    - 'length' holds the number of elements, not the largest index
  7. 7Initialiser Lists- can instantiate and fill an array in one step
    - values delimited by braces and separated by commas
    - eg: int[] units = {147, 323, 89, 933, 540,
    269, 97, 114, 298, 476};
    - eg. char[] letterGrades = {'A', 'B', 'C', 'D', 'F'};
  8. 8Initiliser Lists- when intialiser is used;
    - the 'new'' operator is not used
    - no 'size'value is specified
    - can only be used in the array declaration
  9. 9Array as Parameters- array can be passed to a method as a parameter
    -
  10. 10Array of Objects- elements of an array can be object references
    - eg: store 5 references to String objects
    String[] words = new String[5];
    - does NOT create the objects themselves
    - unless using literals
    - eg: String[] verbs = {"play", "work", "eat", "sleep"};
  11. 11SummaryArray concept:
    - Vector / matrix / table: of data elements, all of same type
    - Vector with subscript, matrix with subscripts

Informationen

Beschreibung
Programming Karteikarten am Arrays, erstellt von Tony Meman am 15/08/2016.
Erstellt von
Tony Meman
Aufrufe
19
Bewertung

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck