Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using parseFloat with JDK 1.1.8

 
Suresh Kanagalingam
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am using JDK 1.1.8 (I can not update to new version because of another software dependancy).
When I tried to use the line below:
updateTable.setFloat (1, Float.parseFloat(fieldList.nextToken()));
I am getting "Method parseFloat(java.lang.String) not found in class java.lang.Float"
Should I import another package? Or 1.1.8 does not have this method?
Thanks
Suresh
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should always check the API for the JDK you're using. In this case, try
Float.valueOf(input).floatValue()
Obviously this was a rather backwards way of getting what you want, so they added parseFloat() in later versions of the JDK.
 
Suresh Kanagalingam
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jim.
Works fine.
Suresh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic