• Post Reply Bookmark Topic Watch Topic
  • New Topic

String-double conversion  RSS feed

 
Lari Hopkins
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?
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 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!