As @Oleg says , you have a completely different syntax in Java and @ luk2302 mentions you can use Streams
Next snippet
int[] a = {1, 2, 3, 4, 5, 6};
int[] result = IntStream.of(1, 5)
.map(i -> a[i])
.toArray();
System.out.println("result = " + Arrays.toString(result));
will print
result = [2, 6]
edit If you need to save logicalarray, a possible solution might be
int[] a = {1, 2, 3, 4, 5, 6};
int[] logicalarray = {0, 1, 0, 0, 0, 1};
int[] result = IntStream.range(0, logicalarray.length)
.filter(i -> logicalarray[i] == 1)
.map(i -> a[i])
.toArray();
System.out.println("result = " + Arrays.toString(result));