Download in
Google Play
358
Share
Save
Sign up
Access to all documents
Join milions of students
Improve your grades
By signing up you accept Terms of Service and Privacy Policy
Sign up
Access to all documents
Join milions of students
Improve your grades
By signing up you accept Terms of Service and Privacy Policy
Syntax ● ● Declare & instantiate ● O datatype [] name = {x,y}; Arrays as objects ● Declare with length ● O datatype [] name = new int[5]; ● are OBJECTS - not primitive types Properties int[] nums = {2, 4, 6}; O O common types: int[] double[] String[] can also have an object list with object data type ex. Cars [] = {carl, car2} O ■ int[] nums = new int [10]; which means if you set list equal to another list, it works as an object reference int[] list1 = {..} int[] list2 = listl; Common algorithms Target ● if you try to update list2, you are technically updating listl index starting at 0, ending at length-1 to get length - list.length can modify the elements in the list, NOT the length of the list can be parameter values and return values (in methods) you can leave them partially filled O loop and conditional O test if nums[x] is your target and save the index Accumulate O initialize a sum variable O loop through, keep incrementing the index and adding nums[x] Maximum/minimum O loop and conditional O initialize a max/min variable AS THE FIRST ELEMENT IN THE ARRAY O test if nums[x] is less/more than your variable, and reset the variable accordingly ● Increasing or decreasing O loop and conditional ■ ensure the loop length only goes up to length-1 to avoid Out Of Bounds errors ● O test if nums[x] is greater/less...
iOS User
Stefan S, iOS User
SuSSan, iOS User
than index[x+1] Removing an element O unordered: rewrite the element you want to remove with the last element of the O array ordered: move all elements AFTER the removed element up an index (nums[3] moves to nums [2]) to overwrite every element following use a placeholder variable, decrement the size variable Inserting an element O O check if there's room move all elements after the intended spot an index HIGHER (nums[4] to nums[5]) and insert at the desired location Swap elements O temp variable and swap using indexes Grow an array O have to make a new array O loop through with indexes (move all original values to the new array index)
Covers arrays, indexing, common algorithms, errors and syntax
0
2
Learn about arithmetic operations, variable assignment, casting, and ranges of variables. (unit 5 stuff)
1
Notes taken for AP Computer Science for first semester!!
0
0
0
Syntax ● ● Declare & instantiate ● O datatype [] name = {x,y}; Arrays as objects ● Declare with length ● O datatype [] name = new int[5]; ● are OBJECTS - not primitive types Properties int[] nums = {2, 4, 6}; O O common types: int[] double[] String[] can also have an object list with object data type ex. Cars [] = {carl, car2} O ■ int[] nums = new int [10]; which means if you set list equal to another list, it works as an object reference int[] list1 = {..} int[] list2 = listl; Common algorithms Target ● if you try to update list2, you are technically updating listl index starting at 0, ending at length-1 to get length - list.length can modify the elements in the list, NOT the length of the list can be parameter values and return values (in methods) you can leave them partially filled O loop and conditional O test if nums[x] is your target and save the index Accumulate O initialize a sum variable O loop through, keep incrementing the index and adding nums[x] Maximum/minimum O loop and conditional O initialize a max/min variable AS THE FIRST ELEMENT IN THE ARRAY O test if nums[x] is less/more than your variable, and reset the variable accordingly ● Increasing or decreasing O loop and conditional ■ ensure the loop length only goes up to length-1 to avoid Out Of Bounds errors ● O test if nums[x] is greater/less...
Syntax ● ● Declare & instantiate ● O datatype [] name = {x,y}; Arrays as objects ● Declare with length ● O datatype [] name = new int[5]; ● are OBJECTS - not primitive types Properties int[] nums = {2, 4, 6}; O O common types: int[] double[] String[] can also have an object list with object data type ex. Cars [] = {carl, car2} O ■ int[] nums = new int [10]; which means if you set list equal to another list, it works as an object reference int[] list1 = {..} int[] list2 = listl; Common algorithms Target ● if you try to update list2, you are technically updating listl index starting at 0, ending at length-1 to get length - list.length can modify the elements in the list, NOT the length of the list can be parameter values and return values (in methods) you can leave them partially filled O loop and conditional O test if nums[x] is your target and save the index Accumulate O initialize a sum variable O loop through, keep incrementing the index and adding nums[x] Maximum/minimum O loop and conditional O initialize a max/min variable AS THE FIRST ELEMENT IN THE ARRAY O test if nums[x] is less/more than your variable, and reset the variable accordingly ● Increasing or decreasing O loop and conditional ■ ensure the loop length only goes up to length-1 to avoid Out Of Bounds errors ● O test if nums[x] is greater/less...
iOS User
Stefan S, iOS User
SuSSan, iOS User
than index[x+1] Removing an element O unordered: rewrite the element you want to remove with the last element of the O array ordered: move all elements AFTER the removed element up an index (nums[3] moves to nums [2]) to overwrite every element following use a placeholder variable, decrement the size variable Inserting an element O O check if there's room move all elements after the intended spot an index HIGHER (nums[4] to nums[5]) and insert at the desired location Swap elements O temp variable and swap using indexes Grow an array O have to make a new array O loop through with indexes (move all original values to the new array index)