Introduction to One Dimensional Arrays

0.0(0)
studied byStudied by 0 people
full-widthCall with Kai
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/23

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

24 Terms

1
New cards

Enhanced For / For Each Loop

A special for loop for going through all the items in a data set.

2
New cards

Index

A location in an array, where a value is stored.

3
New cards

1D Array Creation (Size Known)

type[] name = new type[size];

4
New cards

1D Array Creation (Size and Values Known)

type[] name = {value,value,value,value,..., value};

5
New cards

Replacing a 1D Array

name = new type[]{value,value,value,value,..., value};

6
New cards

Getting the Size of a 1D Array

name.length

7
New cards

Accessing Value at an Index

name[index]

8
New cards

Changing Values in an Array

name[index] = value;

9
New cards

Array

A structure for storing multiple values in a single variable.

10
New cards

Element

A single value stored by an array.

11
New cards

Printing All Values in an Array

for(int x = 0; x < name.length; x++) System.out.println(name[x]);

12
New cards

For Each Loop Format

for(typeOfDataInArray variableName: arrayName) // code using the variableName

13
New cards

Turning a String into a char Array

char[] arrayName = StringName.toCharArray();

14
New cards

Null Pointer Exception

Occurs if an array variable stores null and you try to access or change an element.

15
New cards

Arrays Class

The Arrays class has methods to perform operations on arrays.

16
New cards

Arrays Class Import Statement

import java.util.Arrays;

17
New cards

Arrays Class Method: sort

sort(arrayName) - Sorts the given array.

18
New cards

Arrays Class Method: toString

toString(arrayName) - Prints the given 1D array.

19
New cards

Arrays Class Method: deepToString

deepToString(arrayName) - Prints the given 2D array.

20
New cards

First Index of an Array

The first index in an array is at index 0.

21
New cards

Last Index of an Array

The last index is (number of elements stored) - 1.

22
New cards

Automatic Initialization of int and double Arrays

Values will be initialized to 0 automatically.

23
New cards

Automatic Initialization of boolean Arrays

Values will be initialized to false automatically.

24
New cards

Automatic Initialization of Object Arrays

Values will be initialized to null automatically.