• 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
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

String-double conversion

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble converting a string to a double...

// Select/Extract the load element
nStart = line.indexOf("<load>");
nEnd = line.indexOf("</load>");
String sload = line.substring(nStart+6,nEnd);

// Convert load from a string to an int
double dbLoad = Double.parseDouble(sload);

Bike bike = new Bike(reg, make, model, colour, sload);
bikeList.add(bike);

I have tried a similar technique to convert to an int and it works but with this I am getting the following errors:

2 errors found:
File: C:\Documents and Settings\Lari\My Documents\Huddersfield\Programming\Coursework2\Vehicles.java [line: 103]
Error: cannot find symbol
symbol : constructor Bike(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)
location: class Bike
File: C:\Documents and Settings\Lari\My Documents\Huddersfield\Programming\Coursework2\Vehicles.java [line: 103]
Error: internal error; cannot instantiate Bike.<init> at Bike to ()


Can anyone help?
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Lari Hopkins:
...[line: 103]
Error: cannot find symbol
symbol : constructor Bike(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)...


On line 103, you're trying to call a Bike constructor that takes 5 String arguments, but apparently there is no such constructor defined.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!