Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE EDIT THE LAST 3 METHODS WHERE I PUT STARS AND DO WHAT THE COMMENTS SAY. THE CODE IS IN JAVA PROGRAMMING LANGUAGE. import java.util.AbstractList;

PLEASE EDIT THE LAST 3 METHODS WHERE I PUT STARS AND DO WHAT THE COMMENTS SAY. THE CODE IS IN JAVA PROGRAMMING LANGUAGE.

import java.util.AbstractList; import java.util.List; import java.util.RandomAccess; import java.lang.RuntimeException; import java.util.Arrays;

public class Vector extends AbstractList implements List, RandomAccess { protected Object[] data; protected int size;

public int size() { return size; } private void rangeCheck(int index) { if (index < 0 || index >= size) throw new IndexOutOfBoundsException(""); } @SuppressWarnings("unchecked") private E data(int index) { return (E) data[index]; } private void grow() { int newCapacity = data.length*2; data = Arrays.copyOf(data, newCapacity); } public Vector() { this(10); } public Vector(int initialCapacity) { data = new Object[initialCapacity]; size = 0; } public E get(int index) { rangeCheck(index); return data(index); } public E set(int index, E element) { rangeCheck(index); E oldValue = data(index); data[index] = element; return oldValue; } public boolean add(E element) { if (size == data.length) grow(); data[size++] = element; return true; } public void add(int index, E element) {

************************************** // Add element at index. } public E remove(int index) { *********************************

// Return the removed element } public int indexOf(Object o) {

***************************************** // Returns the index of the first occurrence of the specified element // in this list, or -1 if this list does not contain the element. } public static void main(String[] args) { Vector intlist = new Vector(); Vector stringlist = new Vector(); Vector> intveclist = new Vector>();

for (Integer i = 0; i < 10; i++) { intlist.add(i); }

System.out.println(intlist.indexOf(7)); System.out.println(intlist.indexOf("seven")); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

Do you think Heinz Ruhnau's hedging strategy made sense?

Answered: 1 week ago

Question

Acceptance of the key role of people in this process of adaptation.

Answered: 1 week ago

Question

preference for well defined job functions;

Answered: 1 week ago