How do I compare strings in Java?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
linda cummings cummingslinda14@gmail.com
am 10 Sep. 2016
Beantwortet: Image Analyst
am 10 Sep. 2016
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.
Is == bad? When should it and should it not be used? What's the difference? cummingslinda14 at gmail.com
0 Kommentare
Antworten (1)
Image Analyst
am 10 Sep. 2016
It's not bad. It just depends on what you want to do. That compares strings, as character arrays, on a character by character basis. There are other string functions that do it differently, like strcmp() and strcmpi() and strfind(). I encourage you to look those up in the help to see exactly what they do and how they differ from "==" and to see which is the right operation to do for your current need.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Call MATLAB from Java finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!