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
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 2
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 24.06.2019 02:30
Assume a class window with accessor method getwidth that accepts no parameters and returns an integer. assume further an array of 3 window elements named winarr, has been declared and initialized. write a sequence of statements that prints out the width of the widest window in the array.
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
Other - a written response, no less than arial 12-point font, to the following: of the following, which would you consider is most important to customer service goals? choose one and explain why. (1) accuracy (2) punctuality and attendance (3) courtesy (4) productivity (5) organization
Answers: 1
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
question
Mathematics, 02.10.2019 04:50
question
Mathematics, 02.10.2019 04:50
question
Mathematics, 02.10.2019 04:50
question
Mathematics, 02.10.2019 04:50
question
Mathematics, 02.10.2019 04:50