2
I did not understand the following line of the code below:
ret += this.elem[i]+(i!=this.ultimo?", ":"");
What are the meaning of these operators i!
, ?
and :
{
String ret = "{";
for (int i=0; i<=this.ultimo; i++)
ret += this.elem[i]+(i!=this.ultimo?", ":"");
return ret+"}";
}
It is not i! And yes != , There in front I think q is not an operator but rather the name of the object q was created with a ? , And the : are cocatenated the information
– Matheus Rodrigues
"i!" is not an operator, "i" is a variable (which was defined within the "for"), "!=" is the logical operator "different from"; and "?:" is the ternary operator, is basically a simplified "if" before the "?" is a logical test, if true returns the value before ":", if false, returns the value after the ":".
– Júlio Neto