Filter values of a array

I need to take only selected values from a array. Like i don't 1 values then i need to take next 2 values not the 3rd one like that , i want to ignore 1,3,6, how can i filter values like this pattern.Thanks
[214 byte] By [jolaa] at [2007-10-3 4:34:17]
# 1

> 1,3,6, how can i filter values like this pattern

What is the pattern?

> Like i don't 1 values then i need to take next 2 values not the 3rd one like that

Your english is a little hard to understand so just give more of the pattern for us.

Is it:

1, 3, 6, 10, 15... ?

TuringPesta at 2007-7-14 22:37:55 > top of Java-index,Java Essentials,Java Programming...
# 2

If you are only interested in certain array elements based on their index,

check the index with an if-statement and act appropriately. You can do

anything you like to decide which values to ignore.int ignore = 1;

for(int ndx = 0; ndx < arr.length; ndx++) {

// ignore ndx 1, 3, 6, 10, ...

if(ndx == (ignore * ignore) / 2) ignore++;

else doSomething(arr[ndx]);

}

If doSomething() is trying to build another array then

consider ArrayList, because these can grow.

pbrockway2a at 2007-7-14 22:37:55 > top of Java-index,Java Essentials,Java Programming...
# 3

Sorry for my english.Here is the code that i wrote.I need to ignore 1,3,6,9,12,...etc. values in my arry

private void repaintBoard(String s){

StringTokenizer st1=new StringTokenizer(s,"*");

for(int i=0;i<st1.countTokens();i++){

if(st1.nextToken()=="1"){

jLabel1.setText(st1.nextToken());

}//if

}//while

}//repaintBoard

I need to update my label say 2 in array then 2nd label with the string in the next element in the array.>

jolaa at 2007-7-14 22:37:55 > top of Java-index,Java Essentials,Java Programming...
# 4

Or something like:

for (int i = 0; i < someArray.length; i++) {

if ((i % 3) == 0) continue;

// do whatever you want to with the array at index i now

}

perhaps? Assuming you meant to ignore 0, 3, 6, 9, 12, etc. That 1 in your sequence is anomolous.

paulcwa at 2007-7-14 22:37:55 > top of Java-index,Java Essentials,Java Programming...
# 5
Thanks for your answear.
jolaa at 2007-7-14 22:37:55 > top of Java-index,Java Essentials,Java Programming...