Subjects

Subjects

Companies

Unit 6 - Arrays (Java)

358

Share

Save


Syntax
●
●
Declare & instantiate
●
O datatype [] name = {x,y};
Arrays as objects
●
Declare with length
●
O datatype [] name = new int[5];
●

Sign up

Sign up to get unlimited access to thousands of study materials. It's free!

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];
●

Sign up

Sign up to get unlimited access to thousands of study materials. It's free!

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...

Can't find what you're looking for? Explore other subjects.

Knowunity is the # 1 ranked education app in five European countries

Knowunity is the # 1 ranked education app in five European countries

Knowunity was a featured story by Apple and has consistently topped the app store charts within the education category in Germany, Italy, Poland, Switzerland and United Kingdom. Join Knowunity today and help millions of students around the world.

Ranked #1 Education App

Download in

Google Play

Download in

App Store

Still not sure? Look at what your fellow peers are saying...

iOS User

I love this app so much [...] I recommend Knowunity to everyone!!! I went from a C to an A with it :D

Stefan S, iOS User

The application is very simple and well designed. So far I have found what I was looking for :D

SuSSan, iOS User

Love this App ❤️, I use it basically all the time whenever I'm studying

Alternative transcript:

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)

Unit 6 - Arrays (Java)

358

Share

Save

Syntax
●
●
Declare & instantiate
●
O datatype [] name = {x,y};
Arrays as objects
●
Declare with length
●
O datatype [] name = new int[5];
●
Syntax
●
●
Declare & instantiate
●
O datatype [] name = {x,y};
Arrays as objects
●
Declare with length
●
O datatype [] name = new int[5];
●

Covers arrays, indexing, common algorithms, errors and syntax

Similar Content

0

Unit 6 - Arrays (Java) - Flashcards

Know AP CSA Midterm Revies (Units 1-5) thumbnail

2

AP CSA Midterm Revies (Units 1-5)

Learn about arithmetic operations, variable assignment, casting, and ranges of variables. (unit 5 stuff)

Know AP CSP Notes  thumbnail

1

AP CSP Notes

Notes taken for AP Computer Science for first semester!!

0

python - Flashcards

0

Unit 4 - Loops (java) - Flashcards

0

Operations on Arrays - Flashcards

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...

Can't find what you're looking for? Explore other subjects.

Knowunity is the # 1 ranked education app in five European countries

Knowunity is the # 1 ranked education app in five European countries

Knowunity was a featured story by Apple and has consistently topped the app store charts within the education category in Germany, Italy, Poland, Switzerland and United Kingdom. Join Knowunity today and help millions of students around the world.

Ranked #1 Education App

Download in

Google Play

Download in

App Store

Still not sure? Look at what your fellow peers are saying...

iOS User

I love this app so much [...] I recommend Knowunity to everyone!!! I went from a C to an A with it :D

Stefan S, iOS User

The application is very simple and well designed. So far I have found what I was looking for :D

SuSSan, iOS User

Love this App ❤️, I use it basically all the time whenever I'm studying

Alternative transcript:

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)