subject

I'm trying to create a java program using arraylists to find the median of the list. The lists can be either even or odd in length. If the list is even in length then I take the greater median value. This is what I have so far

int go( List list )
{

Collections. sort(list);

int middle = list. size() / 2;
int size = list. size() % 2;
int midplus = middle + 1;

if (size == 1)
{
return list. get(middle);
}
else
{
return list. get(midplus);
}

}

I keep getting an ArrayIndexOutOfBounds exception and I do not know why.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:30
How do you set up a slide show to play continuously, advancing through all the slides without requiring your interaction? a. click set up slide show, and then select the loop continuously until ‘esc' and show without narration options. b. click set up slide show, and then select the loop continuously until ‘esc' and use timings, if present options. c. click set up slide show, and then select the show presenter view and use timings, if present options. d. click set up slide show, and then select the show without animation and browsed at a kiosk (full screen) options.
Answers: 3
question
Computers and Technology, 23.06.2019 12:30
What is the difference between the internet and the world wide web?
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Need ! will choose brainliest! discuss the role of abstraction in the history of computer software.
Answers: 1
question
Computers and Technology, 24.06.2019 18:20
7. design a circuit with three inputs (x, y, and z) representing the bits in a binary number, and three outputs (a, b, and c) also representing bits in a binary number. when the input is 1, 2, or 3, the binary output should be one lesser than the input. when the input is 4, 5, or 6, the binary output should be one greater than the input. when the input is 0, the output is 0, and when the input is 7, the output is 7. show your truth table, all computations for simplification, and the final circuit.
Answers: 2
You know the right answer?
I'm trying to create a java program using arraylists to find the median of the list. The lists can b...
Questions