1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Maru [420]
3 years ago
8

The following method is intended to remove all values from the ArrayList a that have the same value as val; however, this method

does not work correctly.public void removeValue(ArrayList a, int val) {int i;for (i = 0; i < a.size(); i++) {if (a.get(i) == val) {a.remove(i);}}}If the a contains 2 3 4 3 3 4 4 5 4 3 2 1 and val is equal to 4, then a should contain 2 3 3 3 5 3 2 1 after removeValue is invoked. What does a actually contain after removeValue is invoked? (2 points)1) 2 3 3 4 4 5 4 3 2 12) 2 3 3 3 4 5 3 2 13) 2 4 3 4 5 4 2 14) 2 3 3 3 5 3 2 15) 2 4 3 4 4 5 3 2 1
Computers and Technology
1 answer:
Alona [7]3 years ago
6 0

Answer:

ArrayList a contains [2, 3, 3, 3, 4, 5, 3, 2, 1]

Explanation:

Given

The removeValue method

Required

The content of ArrayList a, after the method is called

From the question, we understand that arraylist a is:

a= [2, 3, 4, 3, 3, 4, 4, 5, 4, 3, 2, 1]

val =4

The function fails when the value to be removed appear consecutively in the list.

4 appears in index 5 and 6 of the list. Only one of the 4's will be removed

So, the updated list will be: [2, 3, 3, 3, 4, 5, 3, 2, 1]

You might be interested in
When you print documents on your laser printer, you see residue from previous images on the output. What two things are the most
Gennadij [26K]

Answer: Seeing images from previous print jobs is a phenomenon called ghosting. It's most likely due to a bad erasure lamp or a broken cleaning blade.

Explanation:

5 0
3 years ago
Write a code segment that will store a dinner selection in option1 based on the values of rsvp and selection. The intended behav
Serggg [28]

The code segment illustrates the use of conditional statements.

The execution of conditional statements is dependent on the truth value of its condition.

The required code segment is as follows:

<em>if (rsvp == true && selection = 1){</em>

<em>       option1 = "Thanks for attending. You will be served beef.";</em>

<em>}</em>

<em>else{</em>

<em>option1 = "Sorry you can't make it.";</em>

<em>}</em>

<em />

The flow of the above code segment is as follows:

  • Check if rsvp is true and selection is 1; if yes, "Thanks for attending....." is saved in option1
  • If otherwise, "Sorry...." is saved in option1

The code segment submitted can be used for several programming languages such as <em>Java, C++, C and C#.</em>

Read more about similar programs at:

brainly.com/question/14166674

5 0
3 years ago
What is the recommended size for bulleted text?
ra1l [238]
The normal size for content area in a powerpoint presentation can be 28 to 30 point size. While on the title it can be 32 to 44.

Better yet, not customize the templates in the powerpoint presentation because these already consist the text and size that fit its design. Even the color is right to maintain harmony.
6 0
4 years ago
Read 2 more answers
What is the first document that colleges review when making admissions decisions
jek_recluse [69]
Usually, the first document colleges check would be SAT or ACT scores
8 0
4 years ago
Read 2 more answers
Your task is to design a method int[] allMatches(int[] values, int size, int a, int b) that returns all values between a and b i
iogann1982 [59]

The program that returns all values between a and b inclusive in the partially filled array values is illustrated below.

<h3>What is a program?</h3>

A computer program means a sequence or set of instructions that is in a programming language for a computer to execute.

Here, the program based on the information given will be:

count = 0

for each v in values

if a <= v <= b

 count++

result = new int[count]

i = 0

for each v in values

if a <= v <= b

 result[i] = v

 i++

return result

Java code:

public class ArrayRange {

public static int[] allMatches(int[] values, int size, int a, int b) {

 int count = 0;

 for (int i = 0; i < size; i++) {

  if(values[i] >= a && values[i] <= b) {

   count++;

  }

 }

 int result[] = new int[count];

 count = 0;

 for (int i = 0; i < size; i++) {

  if(values[i] >= a && values[i] <= b) {

   result[count++] = values[i];

  }

 }

 return result;

}

public static void main(String[] args) {

 int[] a = {11, 3, 9, 4, 2, 5, 4, 7, 6, 0};

 int[] returnedArray = allMatches(a, 8, 3, 7);

 for (int i = 0; i < returnedArray.length; i++) {

  System.out.print(returnedArray[i] + " "

Learn more about program on:

brainly.com/question/1538272

#SPJ1

5 0
2 years ago
Other questions:
  • A type of font that has a decorative tail is A.Serif font B. Sans serif font C. Bubbles font D. Reading font
    7·1 answer
  • ____ is a programming language used to view and manipulate data that is stored in a database.
    6·1 answer
  • Consider the following 32 bit binary representation of the value using IEEE 754 single precision floating point representation.
    15·1 answer
  • A spreadsheet has some values entered:Cell A1 contains 10 cell A2 contains, cell A3 contains 7. you enter in cell A4 the followi
    14·2 answers
  • How can an installation be a tool for community building?
    9·1 answer
  • Instructions
    15·1 answer
  • Weegee confused. <br><br> Why is weegee.org kitty website...?
    8·2 answers
  • What is 1 st genaration of computer ​
    14·2 answers
  • What does it mean that the right mouse button is context-sensitive?
    15·1 answer
  • Write a python program to check whether the number is divisible by 7. If its divisible, print its divisible otherwise find previ
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!