Skip to content

Instantly share code, notes, and snippets.

@ramiresnas
Created August 4, 2017 01:04
Show Gist options
  • Save ramiresnas/4b52de9a8e99fa283e63837d9d4ef75b to your computer and use it in GitHub Desktop.
Save ramiresnas/4b52de9a8e99fa283e63837d9d4ef75b to your computer and use it in GitHub Desktop.
A question about array
import java.util.ArrayList;
import java.util.List;
public class Question {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) {
int ind[] = { 1, 1, 2 ,2 ,2 ,3 ,3, 3, 3, 4, 4, 4};
List x = new ArrayList();
List y = new ArrayList();
int k=4;
for(int i=0 ;i<ind.length;i++){
if(ind[i] == k)
x.add(i);
else
y.add(i);
}
System.out.println(x);
System.out.println(y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment