A direct translation would be something like this:
public static List<Integer> cbSeed(int n) { List<Integer> ol = new ArrayList<Integer>(); ol.add(1); int max = (int) Math.ceil(Math.log(n) / Math.log(2)); for (int i = 0; i < max; i++) { int l = 2 * ol.size() + 1; List<Integer> newOl = new ArrayList<Integer>(ol.size() * 2); for (int el : ol) { int e = el; newOl.add(e <= n ? e : 0); e = l - el; newOl.add(e <= n ? e : 0); } ol = newOl; } return ol; }
As you can see, Java is more verbose :)
You can see that it gives identical results as a Python function:
for (int i = 2; i < 9; i++) System.out.println(i + "\t" + cbSeed(i));
2 [1, 2]
3 [1, 0, 2, 3]
4 [1, 4, 2, 3]
5 [1, 0, 4, 5, 2, 0, 3, 0]
6 [1, 0, 4, 5, 2, 0, 3, 6]
7 [1, 0, 4, 5, 2, 7, 3, 6]
8 [1, 8, 4, 5, 2, 7, 3, 6]