I am trying to convert the tenth digit of an array to a number (10) if it is the value 'x'. I have tried...
if (array[9] === 'x') {
'x' === 10;
};
Thanks
I am trying to convert the tenth digit of an array to a number (10) if it is the value 'x'. I have tried...
if (array[9] === 'x') {
'x' === 10;
};
Thanks
Try this, assuming that array
is a char[]
:
if (array[9] == 'x') {
array[9] = 10;
}
By the way, the code you posted is not valid for Java. This is not an operator: ===
, we must use =
for assignment and the trailing ;
after the last }
is unnecessary.
I edited your code already.
if (array[9] == 'x') //Line 1
{
array[9] = 10; // Line 2
}
On Line 1 you said ===
. Java uses ==
to check if two primitive values are equal in value.
On Line 2 you used three equal signs again. If you want to reassign a variable, you will need to use ONE equal sign.