byte[] a has value of {119}, which is the ascii equivalent of "w", but when I use .toString() to convert it to string, it gives me a weird string. any idea what I did wrong?byte[] a = characteristicRX.getValue(); String rscvString = a.toString(); Log.d("byteToHex", "rscvString = " + rscvString); while ( rscvString != "w" ){ 解决方案 String object takes a parameter of byte[] as an overloaded constructor. Use String rscvString = new String(a); and you should be sortedYou can't use boolean operators to test against strings ie. != or ==. use while ( !(rscvString.equalsIgnoreCase("w") ) the equalsIgnoreCase() method will return a boolean and the ! will force the test against the false. 这篇关于byte [] toString()给出一个奇怪的字符串,而不是实际值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-29 22:53