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 10:00
How do i delete my account on this because i didn't read this agreements and also i put age at xd
Answers: 1
question
Computers and Technology, 23.06.2019 22:00
Technician a says engine assemblies can be mounted longitudinally in a chassis. technician b says engine assemblies can be mounted transversely in a chassis. who is correct?
Answers: 2
question
Computers and Technology, 24.06.2019 09:40
Healthy study habits are best described as
Answers: 1
question
Computers and Technology, 25.06.2019 10:00
Most common level of education for a programmer or software developer
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
World Languages, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
English, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
question
History, 13.09.2020 09:01
question
Mathematics, 13.09.2020 09:01
Questions on the website: 13722367