Java: convert String to Double

Trabla: Java: convert String to Double

Solving:

1. Use Double constructor with String

...

String myStringValue = "1.45";
double myDoubleValue = new Double( myStringValue  );

...

2. Use Double static method valueOf

...

String myStringValue = "1.45";
double myDoubleValue = Double.valueOf( myStringValue  );

...

3.  Use Double static method parseDouble

...

String myStringValue = "1.45";
double myDoubleValue = Double.parseDouble( myStringValue  );

...

No comments:

Post a Comment