I am trying to add some strings in an ArrayDeque but first I have to check if its already full that index. How i can do it?
I have this:
public void processarEntrada(String n){
for ( int i = 0; i <= 3; i++){
planta.add(n);
Each index has to be empty before adding anything
I've had a bit trouble to fully understand the question. What I understood is that you wish to add it into ArrayDeque if only if the array does not contain the string already.
Take a look into Java documentation:
public boolean contains(Object o)
Returns true if this deque contains the specified element. More formally, returns true if and only if this deque contains at least one element e such that o.equals(e).
So I would check if it is in the ArrayDeque and then add it.
if(! planta.contains(theString)) planta.offer(theString);