Unit 2 (Strings and Classes) Flashcards
(12 cards)
array definition
int[] num = new int[length];
int [] num = {1, 2, 3, 4, 5};
Arrays are fixed in length
2d array definition
int[][] matrix = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
};
int[][] jagged = new int[3][];
jagged[0] = new int[2];
jagged[1] = new int[4];
jagged[2] = new int[1];
order of operations
() []
++, –
% / *
+, -
< > <= >=
== !=
&&
||
= += -= etc
When to use .length vs .length()
.length for arrays
.length() for strings
The size of an array is immutable. You cannot ever change the size of an array
Check the answers when tracing to eliminate any options with changed array length
when iterating thru a array, what is the iteration
(int x: arr){
}
when iterating thru a 2d array, what is the iteration