• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Palindrome sentence

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to use a stack + queue to determine whether a sentence is a palindrome (ignoring spaces and punctuation). However my code returns false for the sentence below. Any ideas why? Thanks!

 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dunno. You get two Strings and you compare them, you think they should be the same but they aren't. So print them out and look at them to see why not.
 
El Bel
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:I dunno. You get two Strings and you compare them, you think they should be the same but they aren't. So print them out and look at them to see why not.



Thank you. I thought about printing the strings and realised I needed to pop the characters from the stack onto str and remove characters from queue onto qu.
 
Marshal
Posts: 65809
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use java.util.Stack ←link. It tells you in the documentation what to use instead. Hint: this.
Don't write if (somethingBoolean) return true; else return false; You can find out what to use instead here (beware: old website).
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!