• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Set/Get Bug ?

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't see what I am doing wrong here. I'd swear the boolean should be getting set, but for some reason it is not.


The output is:
parms.getString( "vhs" ) = yes video.inVHS() = false

[ November 13, 2003: Message edited by: Greg Neef ]

Marilyn removed just a couple more lines of code.
[ November 13, 2003: Message edited by: Marilyn de Queiroz ]
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this not a case of the dreaded "==" comparison on Objects (in this case String objects)?
-Barry
 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try outputting the *exact* condition you're testing:
out.println( parms.getString( "vhs" ) == "yes" );
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm at work so I can't check my version of this task but: isn't it important to remember here that if you have 2 Strings s1 and s2,
if ( s2 == s1)
asks whether both s1 and s2 point to exactly the same space in the computer's memory, NOT whether the 2 strings contain the same text.
[ November 14, 2003: Message edited by: Elouise Kivineva ]
[ November 14, 2003: Message edited by: Elouise Kivineva ]
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe one of the author's here had a signature saying something along the lines of "Using "==" to compare Strings is like running with scissors."
 
Greg Neef
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DOH!
This is why coding a 11PM is not a good idea, no matter how much coffee you drink. Thanks all!
 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Runs with Scissors is my Indian name.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by jason adam:
I believe one of the author's here had a signature saying something along the lines of "Using "==" to compare Strings is like running with scissors."


That would be Ernest Friedman-Hill, bartender, author, and the Henny Youngman of Java.
 
reply
    Bookmark Topic Watch Topic
  • New Topic