My program receives some input (a String ). It is possible that the input has the form double , for example, "1.5" . But I would like to convert it to integer , so I can only get 1 .
First, I tried this:
Integer.parseInt(someString);
But that will not work - I guess because of the point . he cannot take it apart.
So I thought that maybe the integer class could create an integer from double . So I decided to create a double and then make it int , for example:
Integer.parseInt(Double.parseDouble(someString));
But apparently there is
No suitable method found for parseInt (double)
So what do you suggest? Is there one line for this? I was thinking of creating a method that removes the dot and all the characters after it ... but that doesn't sound very cool.
Voldemort
source share