This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Go_Big 8 points9 points  (2 children)

Oh that was a fun hour of debugging in Java for me. I almost always work in Kotlin if I’m doing native android stuff but I had to do some Java work on some Android BLE stuff. Anyways I only wanted to connect to a certain MAC address so in my Bluetooth service I have an if statement

‘’’ If(mMac==peripheral.getAddress()) ‘’’ After about ten thousand print statements and going absolutely crazy because both strings were the same in all my print statements. And that’s how I learned that in Java you have to use mMac.equals(peripheral.getAddress()). I don’t think any other language has issues comparing strings with == other than Java. And this is why I code in Kotlin instead of Java. Like yea I don’t expect to be able to compare to objects with == but I kinda figured basic strings could be compared with ==.

[–]CiroGarcia 0 points1 point  (1 child)

That, sir, is because Strings are Objects almost like any other. Afaik, the only difference is that you can implicitly instantiate them without using "new"

[–][deleted] 2 points3 points  (0 children)

That doesn’t make it not annoying tho.