• 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

parseDouble Problem

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Below is the printout in Netbeans of my JavaBean ouput. The last value was typed in the TextField was 5.1 for the audio value. I have tested it may times and it always come out as 0.0
Further down is the code to parse my String to a double from the TextField.
If I need a double, ddoes the user need to type it in with a decimal point in between two numbers. Would anyone guess why it comes out as 0.0?

Here is a link to a screenshot to give you an ideaof what it is I am working on. Thanks.

http://pollscanada.com/screenshot.html


init:
deps-jar:
compile-single:
run-single:
Cabin Fever, Horreur, 2002, 92 Minutes, Audio 0.0
BUILD SUCCESSFUL (total time: 0 seconds)


 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This line

double audio2 = Double.parseDouble(audio1);

declares a local variable and initializes it. Since the block it's in ends immediately after, nobody ever uses this variable. Perhaps there's also a member variable named audio2 that you're trying to assign to? In that case, you need to remove the "double", which turns this from a declaration of a new variable into a simple assignment to an existing variable.
 
henri henri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response. It is quite mind-boggling. I will try your suggestion.
 
henri henri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It turns out it was an oversight of mine. I had declared my double twice. Once as a member and then inside a try.block
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep. Isn't that what I said?
 
reply
    Bookmark Topic Watch Topic
  • New Topic