> 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... ?
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.
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.>
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.