• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/9

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

9 Cards in this Set

  • Front
  • Back
append()
Expands an array by one element and adds data to the new position. The datatype of the element parameter must be the same as the datatype of the array.

When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) append(originalArray, element)

Example

String[] sa1 = { "OH", "NY", "CA"};
String[] sa2 = append(sa1, "MA");
println(sa2);
// Prints updated array contents to the console:
// [0] "OH"
// [1] "NY"
// [2] "CA"
// [3] "MA"
arrayCopy()
Copies an array (or part of an array) to another array. The src array is copied to the dst array, beginning at the position specified by srcPosition and into the position specified by dstPosition. The number of elements to copy is determined by length. Note that copying values overwrites existing values in the destination array. To append values instead of overwriting them, use concat().

Example
String[] north = { "OH", "IN", "MI" };
String[] south = { "GA", "FL", "NC" };
arrayCopy(north, south);
println(south);
// Prints updated array contents to the console:
// [0] "OH"
// [1] "IN"
// [2] "MI"
String[] north = { "OH", "IN", "MI"};
String[] south = { "GA", "FL", "NC"};
arrayCopy(north, 1, south, 0, 2);
println(south);
// Prints updated array contents to the console:
// [0] "IN"
// [1] "MI"
// [2] "NC"
concat()
Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the same datatype.

When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) concat(array1, array2).

Example
String[] sa1 = { "OH", "NY", "CA"};
String[] sa2 = { "KY", "IN", "MA"};
String[] sa3 = concat(sa1, sa2);
println(sa3);
// Prints updated array contents to the console:
// [0] "OH"
// [1] "NY"
// [2] "CA"
// [3] "KY"
// [4] "IN"
// [5] "MA"
expand()
Increases the size of an array. By default, this function doubles the size of the array, but the optional newSize parameter provides precise control over the increase in size.

When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray)

Example
int[] data = {0, 1, 3, 4};
println(data.length); // Prints "4"
data = expand(data);
println(data.length); // Prints "8"
data = expand(data, 512);
println(data.length); // Prints "512"
reverse()
Reverses the order of an array.

Example
String sa[] = { "OH", "NY", "MA", "CA"};
sa = reverse(sa);
println(sa);
// Prints updated array contents to the console:
// [0] "CA"
// [1] "MA"
// [2] "NY"
// [3] "OH"

Syntax
reverse(list)

Parameters
Object, String[], float[], int[], char[], byte[], or boolean[]: booleans[], bytes[], chars[], ints[], floats[], or Strings[]
shorten()
Decreases an array by one element and returns the shortened array.

When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) shorten(originalArray)

Example

String[] sa1 = { "OH ", "NY ", "CA "};
String[] sa2 = shorten(sa1);
println(sa1); // 'sa1' still contains OH, NY, CA
println(sa2); // 'sa2' now contains OH, NY
sort()
Sorts an array of numbers from smallest to largest, or puts an array of words in alphabetical order. The original array is not modified; a re-ordered array is returned. The count parameter states the number of elements to sort. For example, if there are 12 elements in an array and count is set to 5, only the first 5 elements in the array will be sorted.

Example
String[] s = { "deer", "elephant", "bear", "aardvark", "cat" };
s = sort(s);
println(s);
// Prints the contents of the sorted array:
// [0] "aardvark"
// [1] "bear"
// [2] "cat"
// [3] "deer"
// [4] "elephant"

Parameters

list String[], float[], int[], char[], or byte[]: array to sort
count int: number of elements to sort, starting from 0
splice()
Inserts a value or an array of values into an existing array. The first two parameters must be arrays of the same datatype. The first parameter specifies the intial array to be modified, and the second parameter defines the data to be inserted. The third parameter is an index value which specifies the array position from which to insert data. (Remember that array index numbering starts at zero, so the first position is 0, the second position is 1, and so on.)

When splicing an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index)

Example
String[] b = { "VA", "CO", "IL" };
a = splice(a, b, 2); // Splice one array of values into another
println(a);
// Prints the following array contents to the console:
// [0] "OH"
// [1] "KY"
// [2] "VA"
// [3] "CO"
// [4] "IL"
// [5] "NY"
// [6] "CA"
subset()
Extracts an array of elements from an existing array. The list parameter defines the array from which the elements will be copied, and the start and count parameters specify which elements to extract. If no count is given, elements will be extracted from the start to the end of the array. When specifying the start, remember that the first array element is 0. This function does not change the source array.

When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) subset(originalArray, 0, 4)

Example
String[] sa1 = { "OH", "NY", "CA", "VA", "CO", "IL" };
String[] sa2 = subset(sa1, 1);
println(sa2);
// Prints the following array contents to the console:
// [0] "NY"
// [1] "CA"
// [2] "VA"
// [3] "CO"
// [4] "IL"
println();
String[] sa3 = subset(sa1, 2, 3);
println(sa3);
// Prints the following array contents to the console:
// [0] "CA"
// [1] "VA"
// [2] "CO"