• 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

String-double conversion

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic