Arrays

Description

Programming Flashcards on Arrays, created by Tony Meman on 15/08/2016.
Tony Meman
Flashcards by Tony Meman, updated more than 1 year ago
Tony Meman
Created by Tony Meman over 7 years ago
4
0

Resource summary

Question Answer
Array - ordered list of values - a particular value is referenced using 'array name [ ]'
Array Elements - store multiple values of the same type - can be primitive type or object reference -
Declaring 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];
Using Arrays - iterator version of the for loop can be used when processing array elements: for (int variablename: scores) System.out.println (variablename);
Bounds Checking - once created, array size is fixed - java will recognise if a element is outside of array index and prints 'ArrayIndexOutOfBoundsException'
Bounds Checking (cont.) - every array has a public constant called 'length' - referenced: variablename.length - 'length' holds the number of elements, not the largest index
Initialiser 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'};
Initiliser Lists - when intialiser is used; - the 'new'' operator is not used - no 'size'value is specified - can only be used in the array declaration
Array as Parameters - array can be passed to a method as a parameter -
Array 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"};
Summary Array concept: - Vector / matrix / table: of data elements, all of same type - Vector with subscript, matrix with subscripts
Show full summary Hide full summary

Similar

HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Historical Development of Computer Languages
Shannon Anderson-Rush
Useful String Methods
Shannon Anderson-Rush
Flvs foundations of programming dba 2
mariaha vassar
computer systems and programming quiz
Molly Batch
Python Quiz
karljmurphy
Think Python
tsilvo2001
C Programming
Miki Rana
Generations of Programming Languages
Balikkoftesi
Mapa Conceptual - Arreglos
ciroivan94