• Post Reply Bookmark Topic Watch Topic
  • New Topic

Iterator logic problem  RSS feed

 
Mick Furze
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I've been working on a study project for ages and I think one of the things that is holding me back is not knowing how to correctly do the loop logic for a bit of code that aims to create a new chat room, or to connect users to an existing one.

This code seems to create a new room everytime someone connects even if the roomname is identical. I'm pretty sure the approach is all wrong but not sure where start putting it right.
Any help would be great.

 
Stephan van Hulst
Saloon Keeper
Posts: 7991
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never compare strings using ==. Use equals() instead.

Also, why are you using an iterator instead of an enhanced for loop?
 
Mick Furze
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. That was indeed the problem. I'll try out enhanced for loops as well.

Thanks
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Mick!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!