Consider the following "SequenceList" class: import java.util.ArrayList; public class SequenceList { //constant and instance variables private final static int maxSize = 20; //To control list size private ArrayList myList; // hold a list of unknown number of integer values %3! ... public void displayList ( ) {..} // assume this method is given and it displays elements of myList }//end Sequencelist 1) Complete "SequenceList" class by adding: A. [5 points] Constructor method that receives an array list of initial integer values; accept number of integers no more than maxSize. If listA has more than maxSize elements, the first maxSize elements are assigned to myList. public Seguancel ist(Arrayl ist listA) {..}
Consider the following "SequenceList" class: import java.util.ArrayList; public class SequenceList { //constant and instance variables private final static int maxSize = 20; //To control list size private ArrayList myList; // hold a list of unknown number of integer values %3! ... public void displayList ( ) {..} // assume this method is given and it displays elements of myList }//end Sequencelist 1) Complete "SequenceList" class by adding: A. [5 points] Constructor method that receives an array list of initial integer values; accept number of integers no more than maxSize. If listA has more than maxSize elements, the first maxSize elements are assigned to myList. public Seguancel ist(Arrayl ist listA) {..}
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 19RQ
Related questions
Question
Expert Solution
Step 1
1. a) listA obj=new listA();
obj.displaylist();
b) bool a,b;
int b=new int[-18,-1,6,9,12];
return true;
int a=[1,-4,9,-16,-7,9];
return false;
c)public class newlist{
public static void main(String[] args) {
List<Integer> objArray = new ArrayList<Integer>();
objArray.clear();
objArray.add(2);
objArray.add(-3);
objArray.add(4);
System.out.println("Array before removing an element "+objArray);
Iterator<Integer> iterator = objArray.iterator();
while(iterator.hasNext()) {
Integer next = iterator.next();
if(next < 0) {
iterator.remove();
}
}
System.out.println("Array after removing an element"+objArray);
}
}
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT