• Post Reply Bookmark Topic Watch Topic
  • New Topic

Comparator/List Iterator/GUI popup message  RSS feed

 
Tony Kurt
Greenhorn
Posts: 9
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I am trying to compare the elements in the list iterator and I wrote a condition if this condition is true then I want to remove the elements from the list depending on this condition. However my code is not working it gave no error message but somehow this part is not executed.





then in GUI



Could you please help me.
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This code is probably the problem. Don't use == to compare Strings, or any objects for that matter. Use equals(). The == operator is only for numbers.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The bigger problem is that the compare() method pretends that all Job objects are equal, and worse still it updates some list somewhere if it's called with two which actually are. This is bad because when you sort a list it is unpredictable which objects will be compared and how often they will be compared.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!