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 '.

5th Aug 2017, 6:43 AM
Nazhan Harzula
Nazhan Harzula - avatar
1 Antwort
+ 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);
5th Aug 2017, 6:58 AM
Hatsy Rei
Hatsy Rei - avatar