If your difficulty is creating objects, try this:
import java.util.ArrayList;
public class Porcentagem {
private final int valor;
public Porcentagem(int valor) {
this.valor = valor;
}
public int getValor() {
return valor;
}
public static void main(String[] args) {
ArrayList<Porcentagem> q = new ArrayList<>();
for (int i = 0; i < 100; i++) {
q.add(new Porcentagem(i % 5 == 0 ? 1 : 2));
}
}
}
Basically, this algorithm repeatedly inserts an element with a value of 1 followed by four elements with a value of 2. Thus, it guarantees a deterministic order where the 1s will not be on each other's side. If this is not what you want, please explain it better.
Note: There is no class ArrayQueue
in java. I only found ArrayList
and ArrayDeque
. I used ArrayList
in the above code, but you can use whichever one you like best.