subject
Computers and Technology, 02.04.2021 19:20 Kana81

Now let's write the add method for our SimpleArrayList. First, create a SimpleArrayList class with a single public constructor that initializes the list with a passed array of Object references. You should assert that the passed array is not null. Next, implement a getter getValues() which returns the object array that the list uses to store values. (This is purely for testing.) Also implement size() which returns the size of this list as an int. Now write the add method, which takes the position to add at as an int as its first parameter and the Object reference to add as its second. add should add the element to the list, increasing the size by one and shifting elements after the add position backward. You should assert that the passed position is valid for this list. But note that you should allow adding a new item to the end of the existing list. When you are done, here is how your SimpleArrayList class should work: 1 SimpleArrayList list = new SimpleArrayList(new int[] {1,5});
2 System. out. println(Arrays. toString(list. getValues())); // prints {1, 5}
3 System. out. println(list. size()); // prints 2
4 list. add(1, 2);
5 System. out. println(Arrays. toString(list. getValues())); // prints {1, 2, 5}
6 System. out. println(list. size()); // prints 3

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:40
Write an assembly program with the following specifications.a). in the main block, you should have two registers r4 and r5. they should be checked in an infinite loop. if r4 is greater than r5, then the greater subroutine will be called. if r4 is less than r5, then the less subroutine will be called. if r4 equals r5, then no operations will be done
Answers: 1
question
Computers and Technology, 22.06.2019 10:30
Dave has to create animations for a game. which tool can dave use?
Answers: 3
question
Computers and Technology, 22.06.2019 16:30
Corey set up his presentation for delivery to his team.the information he had to convey was critical to their job performance.he knew he would need a lot of time to explain each point
Answers: 3
question
Computers and Technology, 23.06.2019 00:00
What season was better from fortnite?
Answers: 2
You know the right answer?
Now let's write the add method for our SimpleArrayList. First, create a SimpleArrayList class with a...
Questions
question
History, 30.06.2019 20:00
question
English, 30.06.2019 20:00
Questions on the website: 13722360