Hey there! any question in your mind? Ask It Now!.

Popular Categories





Best way to Convert a String having Decimal point to Double?

0 votes
149 views
asked in Programming by monika (2,040 points)
Hello I have a string containing decimal values now I want to remove decimal values and want to make it double.
 
I am trying this: 
Like String A = "34000.898989";
int a =Integer.parseInt(A); 
String result = String.format
 
But not working.Please help me out!

1 Answer

+1 vote
answered by jack (1,440 points)
selected by monika
 
Best answer

You have parse the string like this,After then you can remove decimals from the string
See this code.


 String A = "34000.898989";

 double bDouble = Double.parseDouble(A);
 int finalA = (int)bDouble;
              
 

I hope you got my point.

commented by raman (530 points)
@jack you are right, its the right way to convert a string.
commented by monika (2,040 points)
Thanks @jack i got my answer. :)

Related Questions

+3 votes
1 answer 645 views
+2 votes
2 answers 788 views
–1 vote
0 answers 111 views
+6 votes
2 answers 2,242 views
+1 vote
1 answer 778 views
+4 votes
5 answers 713 views
+2 votes
1 answer 141 views
+1 vote
1 answer 145 views
0 votes
0 answers 71 views

Not a Member yet?

Ask to Folks Login

My Account
847 Folks are online
74 members and 773 guest online
Your feedback is highly appreciated