How do i get 30 values from the list every time using java.

srikotesh
srikotesh used Ask the Experts™
on
Hi Experts,

I have a list having values
from the list i want to display an average of 30 values
like let suppose
list having 100 values i want to display 3,6,9,.....up to 30 values
is it possible to get 30 values out of list size?

list size i am not sure how much it is?


list size is 100-->30( i need 30 values from the list)
                   200-->30
                   300-->30
                   400-->30
                   500-->30

Thanks,
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016
Commented:
Something like the following maybe?


int listSize = list.size();
int stepSize = listSize / 30;
for(int i = 0;i<listSize;i+=stepSize) {
  Object o = list.get(i);
}

Open in new window

Author

Commented:
Superb

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial