Source in use
String[] array_word;
array_word = readMessage.split("");
for(int i=1;i<65;i++){
if(array_word[i] == '0'){
array_word[i] = null;
}
}
I'm putting what I received as a readMessage into an array called array_word using the split function.
Note that readMessage only receives signals consisting of 0 or 1. 10101010 to 1111000 and so on... There are 64 coming in.
There is an error in writing the code because I want to change the value of 0 to NULL.
android java compare string
Change it to if(array_word[i] == '0')
instead of if(array_word[i].equals("0")
Below is the code tested with jshell.
jshell> String b = "11110000"
b ==> "11110000"
jshell> String[] array_word = b.split("")
array_word ==> String[8] { "1", "1", "1", "1", "0", "0", "0", "0" }
jshell> array_word[0] = null
$3 ==> null
jshell> array_word
array_word ==> String[8] { null, "1", "1", "1", "0", "0", "0", "0" }
© 2024 OneMinuteCode. All rights reserved.