Most voted "equals" questions
10 questions
Sort by count of
-
16
votes4
answers930
viewsBehavior of different ways of comparison in Java
If for example I have the code below, I am comparing the reference of the objects in the case ex1 and ex2 and not the object itself, correct? Pessoa ex1 = new Pessoa(); Pessoa ex2 = new Pessoa();…
-
5
votes3
answers369
viewsStringbuffer.equals and String.equals difference in Java
The behaviour of the method equals class StringBuffer Java is different from equals class String? If yes, how would I overwrite that?…
-
3
votes1
answer307
viewsUse of equals and inheritance
I have a parent class and in it I have a equals and I have other daughter classes of this father class and in them I want to overwrite the equals to compare particular attributes of these daughter…
-
3
votes2
answers3704
viewsHow does the equals method work?
I stopped in an exercise of a book I’m reading and in this shows an example of overloading the method equals, I even understood the concept that he compares the reference between two objects, but in…
-
3
votes1
answer69
viewsComparison of index (get) in Array List not working properly
I’ve been trying to compare a string (right answer) for an alternative question as an example in a project I’m developing, but I can’t succeed in all the different ways I try. The goal is that every…
-
1
votes1
answer170
viewsHow to override equals for it to compare: primitive objects and keys (int, String, double)
Is there any way to compare? because in my code, if it is not int or Object the program throws an exception. To be able to use in the method contains the Listsequential class. Classe Pessoa public…
-
1
votes2
answers162
viewsEquals() and Hashcode() superscript
I’m learning to use the equals() and hashCode(), and I was taught that Eclipse overwrites this method for us. But I’m trying to buy two attributes to tell if one object is the same as the other.…
-
0
votes2
answers156
viewsHow to validate an upload by file name?
I am trying to validate the upload of a file , and the same should always be called new.mpg, if not, the program will not work. function validarNomeArquivo(){ //variavel que recebe o nome do arquivo…
-
0
votes3
answers597
viewsHow does the equals() method work in Java?
At the time I will use the method equals() I place an object of the type Person and it works, because? How it works being that the object I passed is not the type Object? I know all this has to do…
-
-2
votes1
answer66
viewsStack overflow exception being generated in the instance method "Equals()"
I created a class called MyList<T>, with the intention of reproducing the class List, and I overwrote the method Equals to compare your instance with another of the same class, as follows:…