equals

String comparison via the Java switch statement

I need to compare the value that is in the object with each value from the prepared array. How do I do this? In my case, it g ... ch (text) { case labelsStr[0]: startActivity(new Intent(context, Color.class)); break; }

The dependence of HashSet on the redefinition of equals() and hashCode () for the elements of the set

I was given the task to make two different objects of the User class with the same fields and 4 options for adding them to Ha ... d how it still works. What is the idea of the HashSet class when identifying what is considered a duplicate and what is not?

How to split a String into separate words in Java?

Hello everyone! I have such a task, it is necessary to divide a string into words, write it to an array and then compare each ... (i = 0; i < s.length; i++) { if (s[i].equals(s[i + 1])) { System.out.println(s[i]); } } }

What is the difference between == and equals in Java?

Please tell me why in the code below == and equals give the same result? import static java.lang.System.*; public class A { ... s.prop1 = prop1; this.prop2 = prop2; } private String prop1 = null; private String prop2 = null; }

How string interning works

Colleagues! I would like to ask you some questions that I have had while studying the language in more detail .NET and the ... ferent results in the end? I understand that in this case we are comparing objects, not content. But why didn't they unite?

Problem with LinkedList extra space is added when Assert. assertEquals()

I have my own LinkedList implementation, I'm trying to test it using junit, but I get an error due to the fact that an extra ... expected.addLast("A"); linkedListOwn.addFirst("B"); Assert.assertEquals(expected, linkedListOwn); }

How does the equals method work?

I stopped at an exercise from a book I'm reading and in this one shows an example of method overload equals, I even understoo ... System.out.println("Contas iguais"); } else { System.out.println("Contas difentes"); } } }

Equals method in Java

Well I have a doubt right there in the Object parameter, the fact is that at the time I vo use this method I put an object of ... Person) obj; if (this.salario == contaDiferente.salario) { return true; } else { return false; }

Index (get) comparison in Array List not working properly

I've been trying to compare a string (right answer) to an alternative of a question as an example in a project I'm developing ... } EDIT: using break inside if in switch-case consisted the big problem of the code, this now neat and working with equals.