about | help | code help+videos | done | prefs |
orion.a.smith@gmail.com apcsa-arrays
Description:AP CS A - Array problems (Unit 6)
Go down to the bottom of every CodingBat problem page and you will find a great and helpful introduction to arrays written by Nick Parlante, creator of CodingBat. Remember to use square brackets to refer to an element of an array, like
a[0]You can change the value of this element by using an assignment, like
a[0] = 5;When creating an array, use the data type of the elements followed by square brackets. Arrays use the new keyword since they are objects, but are the only Java object type that don't use a constructor method (with parentheses). Instead, they use square brackets again.
int[] a = new int[5]; // array of 5 int elementsYou can use a loop that goes through all the array elements in order (often a for loop). Much like looping problems with String, array looping problems will often have a loop control variable starting at 0 and incrementing while less than the length of the array. Many (but not all!) looping problems can also be completed using the enhanced for loop, sometimes also called the for-each loop.
Basic Array Problems
apcsaArraysCreateStringsArray apcsaArraysCreateThree apcsaArraysFindLength H apcsaArraysGetFirstElement H apcsaArraysGetLastElement H apcsaArraysConcatThreeStrings apcsaArraysConcatThreeFirstCharacters apcsaArraysConcatThreeNthCharacters apcsaArraysGetFirstThreeElements apcsaArraysGetFirstMiddleLastElements
Swapping (no loops)
apcsaArraysSwapFirstElements apcsaArraysSwapLastElements apcsaArraysSwapFirstElementsWhenDisordered apcsaArraysSwapEndElements
Array creation (with and without loops)
apcsaArraysSmallInterleave apcsaArraysAddToEnd apcsaArraysAddToStart apcsaArraysJoinFirstLast apcsaArraysSwitchJoiner
Looping Array Problems
apcsaArraysHasFive apcsaArraysDivisibleByFive apcsaArraysComputeArraySum apcsaArraysAddEvenIndexElements apcsaArraysAddLargerOfPair apcsaArraysSwapPairElements apcsaArraysFindMinArrayValue apcsaArraysFindMinArrayIndex apcsaArraysFindMaxArrayValue apcsaArraysFindMaxArrayIndex apcsaArraysSwapLeastWithFirst apcsaArraysSwapLeastTwoToFront apcsaArraysSwapMirrorElements apcsaArraysSwapPairElementsWhenDisordered apcsaArraysIsEvenOdd apcsaArraysCountIncrements apcsaArraysMoreEvens apcsaArraysPrintArrayValues apcsaArraysPrintArrayValuesWithCommas apcsaArraysPrintArrayValuesWithBrackets apcsaArraysPrintArrayValuesReversedWithBrackets apcsaArraysPrintOddIndexArrayValuesWithBrackets apcsaArraysPrintEvenIndexArrayValuesWithBrackets apcsaArraysPrintEvenThenOddIndexArrayValuesWithBrackets apcsaArraysThreeSequences
Harder Array Problems
apcsaArraysPairMax apcsaArraysFindMultiples apcsaArraysSingleBubbleSortPass
Two-Array Problems
These are definitely a little harder.
apcsaArraysAlternateInputs
apcsaArraysMergeInputs
apcsaArraysFindShared
apcsaArraysAreAnagrams
Authoring docs
Copyright Nick Parlante 2017 - privacy