Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Empty ArrayList fed by tokens  RSS feed

 
Frank Poupard
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, in the following program I'm looking for matches between some key words and some words contained in an array. The matches are expected to feed an ArrayList, which is unfortunately empty at the end. For example, if the input is , I expect to have as ouptut. It's a bit dummy for the moment but I woud like to make it work before any improvement. Thanks for your help.


 
Stephan van Hulst
Saloon Keeper
Posts: 7805
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frank, Strings are objects, and as such the == operator performs identity comparison, not value comparison.

You should get into the habit of avoiding == when not dealing with primitives or enums.
 
Frank Poupard
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad, thank you very much !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!