• 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/10

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;

10 Cards in this Set

  • Front
  • Back
join()
Combines an array of Strings into one String, each separated by the character(s) used for the separator parameter. To join arrays of ints or floats, it's necessary to first convert them to Strings using nf() or nfs().

Syntax
join(list, separator)

Example
String[] animals = new String[3];
animals[0] = "cat";
animals[1] = "seal";
animals[2] = "bear";
String joinedAnimals = join(animals, " : ");
println(joinedAnimals); // Prints "cat : seal : bear"

// Joining an array of ints requires first
// converting to an array of Strings
int[] numbers = new int[3];
numbers[0] = 8;
numbers[1] = 67;
numbers[2] = 5;
String joinedNumbers = join(nf(numbers, 0), ", ");
println(joinedNumbers); // Prints "8, 67, 5"
match()
This function is used to apply a regular expression to a piece of text, and return matching groups (elements found inside parentheses) as a String array. If there are no matches, a null value will be returned. If no groups are specified in the regular expression, but the sequence matches, an array of length 1 (with the matched text as the first element of the array) will be returned.

To use the function, first check to see if the result is null. If the result is null, then the sequence did not match at all. If the sequence did match, an array is returned.

If there are groups (specified by sets of parentheses) in the regular expression, then the contents of each will be returned in the array. Element [0] of a regular expression match returns the entire matching string, and the match groups start at element [1] (the first group is [1], the second [2], and so on).

Syntax
match(str, regexp)
matchAll()
This function is used to apply a regular expression to a piece of text, and return a list of matching groups (elements found inside parentheses) as a two-dimensional String array. If there are no matches, a null value will be returned. If no groups are specified in the regular expression, but the sequence matches, a two dimensional array is still returned, but the second dimension is only of length one.

To use the function, first check to see if the result is null. If the result is null, then the sequence did not match at all. If the sequence did match, a 2D array is returned.

If there are groups (specified by sets of parentheses) in the regular expression, then the contents of each will be returned in the array. Assuming a loop with counter variable i, element [i][0] of a regular expression match returns the entire matching string, and the match groups start at element [i][1] (the first group is [i][1], the second [i][2], and so on).

Syntax
matchAll(str, regexp)
nf()
Utility function for formatting numbers into strings. There are two versions: one for formatting floats, and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers.

As shown in the above example, nf() is used to add zeros to the left and/or right of a number. This is typically for aligning a list of numbers. To remove digits from a floating-point number, use the int(), ceil(), floor(), or round() functions.

Syntax
nf(num, digits)
nf(num, left, right)
nfc()
Utility function for formatting numbers into strings and placing appropriate commas to mark units of 1000. There are two versions: one for formatting ints, and one for formatting an array of ints. The value for the right parameter should always be a positive integer.

For a non-US locale, this will insert periods instead of commas, or whatever is apprioriate for that region.

Syntax
nfc(num)
nfc(num, right)
nfp()
Utility function for formatting numbers into strings. Similar to nf() but puts a "+" in front of positive numbers and a "-" in front of negative numbers. There are two versions: one for formatting floats, and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers.

Syntax
nfp(num, digits)
nfp(num, left, right)
nfs()
Utility function for formatting numbers into strings. Similar to nf(), but leaves a blank space in front of positive numbers so they align with negative numbers in spite of the minus symbol. There are two versions: one for formatting floats, and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers.

Syntax
nfs(num, digits)
nfs(num, left, right)
split()
The split() function breaks a String into pieces using a character or string as the delimiter. The delim parameter specifies the character or characters that mark the boundaries between each piece. A String[] array is returned that contains each of the pieces.

If the result is a set of numbers, you can convert the String[] array to to a float[] or int[] array using the datatype conversion functions int() and float(). (See the second example above.)

The splitTokens() function works in a similar fashion, except that it splits using a range of characters instead of a specific character or sequence.

Syntax
split(value, delim)
splitTokens()
The splitTokens() function splits a String at one or many character delimiters or "tokens." The delim parameter specifies the character or characters to be used as a boundary.

If no delim characters are specified, any whitespace character is used to split. Whitespace characters include tab (\t), line feed (\n), carriage return (\r), form feed (\f), and space.

After using this function to parse incoming data, it is common to convert the data from Strings to integers or floats by using the datatype conversion functions int() and float().

Syntax
splitTokens(value)
splitTokens(value, delim)
trim()
Removes whitespace characters from the beginning and end of a String. In addition to standard whitespace characters such as space, carriage return, and tab, this function also removes the Unicode "nbsp" character.

Syntax
trim(str)
trim(array)