0
The way to change int a char 'H ' on the data array of integer
There is a data array of integer, but wanted to changed in a state where if an array of the had the rate of less than 20 then replaced letters 'H '.
1 Answer
+ 10
You can't store characters in integer arrays. I'm not sure what you plan on doing, but if you wanted to print the entire array and exclude those elements with values less than 20, you can do:
for (int i = 0; i < array_size; i++)
{
if (array[i] < 20) System.out.println('H');
else { System.out.println(array[i]); }
}
//or you can set the array values to 72, which is the ASCII value of 'H', then cast it to char.
int x = 72;
System.out.println((char)x);