• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble inputting float variables  RSS feed

 
chaitanya gollapudi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hieverbody,
Can anyone please tellme how to input floating point variables.I tried using Integer.parseInt for integers and it worked.But Double.parseDouble isnt working.How to deal with this.Thank u all.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
Welcome to JavaRanch!
parseDouble() is a perfectly good routine -- can you be more specific than "isn't working?" Maybe show the code you tried, tell us what happened, and what you expected to happen instead.
 
chaitanya gollapudi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Ernest,
i wrote a program that prompts to give cost of a thing in floating point and iused parseDouble method and i use JBuilder to compile and run my programs.While debugging its giving an error message saying
method parseDouble[java.lang.String]not found in class java.lang.Double.
But it worked fine when i used parseInteger method.Why is this so?
Thank u again in advance.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick check of the Javadocs shows that Double.parseDouble() was introduced in JDK 1.2 -- looks like you're working with a very old version of Java. You could instead use new Double("123.213").doubleValue() ; this ought to work in JDK 1.0 and up. Or you could upgrade to use a more recent Java 2 platform.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!