Answer:
Explanation:
get method is used to get the number at any index in the Arraylist
nums is the arraylist which uses the get method by passing the index 8 to the get method.
It returns the value at 8th index and store it in variable x.
feel free to comment if you need any help!
The statement is:
int x = nums.get(8);
Sample code:
import java.util.ArrayList;
public class Main
{
public static void main(String[] args) {
ArrayList<Integer> nums = new
ArrayList<Integer>();
nums.add(1);
nums.add(2);
nums.add(3);
nums.add(4);
nums.add(5);
nums.add(6);
nums.add(7);
nums.add(8);
nums.add(9);
int x = nums.get(8);
System.out.println(x);
}
}
Output:
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
PLEASE COMMENT IF YOU NEED ANY HELP!
java please D Question 25 O pts Assign the Integer stored in index number 8 of...
IN JAVA please Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. Your code will be tested for runtime. Code which does not output a result in logarithmic time (making roughly log(2) N comparisons) will fail the tests. A sample main function is provided so that you may test your code on sample inputs. For testing purposes, the...
A java exercise please!
Write a static method named swapHavles that takes an ArrayList of integers as a a parameter and returns a new ArrayList that has every element in the second half of the original ArrayList swapped with every element in the first half of the original ArrayList. Note: • You can assume that the ArrayList passed to this method as a parameter always contains an even number of elements and will always contain at least two elements. For...
Could someone
please solve it? its java
- The average of each integer array is stored in another array coedum Answer the three questions below using this program public class averageMultidin 2 public static void main(String[] args) { int(01) tablet (1,2,3), (0,57,101) },{ (38,-80,95),(-10,13,34) ) ); 5 3 double[] sumar - new double 4); int sum = 0; int index = 0; 9 11 System.out.println("Sizesi "table.length-table().length. table[ejto).length); 12 for (int i = 0; i < table.length; i++) for (int j...
Java: please ignore my answer, do question 3.
Question 3. 15 pts. The equalsO method of the ArrayList<E> class takes another list as a parameter and returns true if the two lists contain the same elements in the same order, and false otherwise middle section of the code below so that the output is truetrue . Remember that add (int index, E element), and set (int index, E element). you can put elements into an ArrayList with the methods add(E...
PLEASE ANSWER ALL OF THEM, I REALLY APPRECIATE IT
PLEASE IGNORE THE SELECTED ANSWERS
Question 9 3 pts Which best describes the meaning of a 1 (true) being output? Assume v is a large array of ints. int i; bool si for (i = 0; i < N_SIZE; Hi) { if (v[i] < 0) { S-true; else S = false; } cout << si O first value is negative all values are negative some value other than the last is...
python programming
Canvas → XCO Question 28 10 pts (SHORT ANSWER) Write Python statements to do the following (number your answers); 1. Create a constant PI and assign it 3.1415 2. Calculate the volume of the cone and store it in the variable volume . Given the formula to compute the volume of a cone is: II-> (5) • Assume: the variables r and h are already assigned with values 3. Display the computed volume on the console as follows...
I only need help with question 5! Thank
you!
Question 4 4 pts Consider this variant of the linear search algorithm which attempts to speed up the search by reducing the number of iterations of the for loop by approximately one-half. During each pass of the loop, the algorithm performs two comparisons rather than one comparison as in linear Search(). The two comparisons compare the elements at indices i and pList size() - 1-i to pKey for equality. If a...
CSC110
Lab 6 (ALL CODING IN JAVA)
Problem: A text file contains a paragraph. You are to read the
contents of the file, store the UNIQUEwords and count the
occurrences of each unique word. When the file is completely read,
write the words and the number of occurrences to a text file. The
output should be the words in ALPHABETICAL order along with the
number of times they occur and the number of syllables. Then write
the following statistics to...
Eclipse Java Oxygen Question 11 pts A compile-time error occurs when Group of answer choices c. there’s a syntax error in a Java statement a. the Java compiler can’t be located b. bytecodes can’t be interpreted properly c. there’s a syntax error in a Java statement Flag this Question Question 21 pts An error that lets the application run but produces the wrong results is known as a Group of answer choices d. syntax error c. logic error a. runtime...
Question 11 15 pts A production manager believes that a container filling line for peanut cans is under-filling the 1 lb containers. He collects a sample of 50 peanut cans and weighs them. He computes a test value of Z -1.84. At the .05 level of significance, can the manager conclude that the production line is under- filling the containers? What about the .01 level of significance? HTML Editor B I VA A. I E III IX X, EE DE...