Arrays - Day 3 Flashcards

1
Q

Initialising the array

A

Datatype[] arrayVarName = {elem1e,elem2};

Datatype[] arrayVarName = new dataType[size];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Locating array index

A

Arrayvarname[index]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Arrays are objects?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Unlike python, arrays are pretty restricted and can only hold 1 data type

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

For loop in array for elements

A

For (int index = 0; index < arrayName.length; index++) {

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

For each loops

A

Splits up each element, no use of indexing

For(dataType variableName: arrayName){

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Multi dimensional arrays

A

Each element of the array holding other arrays.

For a 2D array:

Datatype[][] arrayVarName = new dataType[rowsize][columnsize];

Row is length of array
Column is array of each array element

Columnsize is optional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When a value isn’t initialised in an array. What happens

A

It saves the value as zero/defaults.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Command line arguments

A

Inputs passed into the program through the command line

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to use command line

A

Need the parameter

“String[] args” in the main

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Input through command line example

A

System.out.printIn(“hello” +args[0]):

NOT TESTED for exam. WILL USE SCANNER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly