Linked Questions
14 questions linked to/from Cast Double to Integer
87 votes
5 answers
409k views
How to convert Double to int directly? [duplicate]
May be this is silly question. I want to get rid of the fractional part of the Double number. But I cant do that. It shows the error that incompatible types. What to do? Double to int conversion in ...
1 vote
2 answers
2k views
I am facing a class cast exception, from java.lang.Double to java.lang.Integer [duplicate]
I am writing a JUnit test case for a method that has a getValue() method which returns an Object, the getValue() returns the value I pass inside setValue() and In this case when I pass a double value ...
-1 votes
4 answers
464 views
Double to int and double to int [duplicate]
I want to know what happened when Double invert to int on my example? this case is right Double d = 123.13; int i = (int)(Math.random()*d); this case is wrong Double d = 123.13; int i = (int)(d); ...
-9 votes
7 answers
3k views
How to extract these integer values from ArrayList<String> [duplicate]
I am having a ArrayList<String> abc in which I am getting this value [64.3, 25.1, 44.3, 34.2, 6.4, 48.5, 35.5, 59.5, 54.6, 26.6, 11.2, 50.3, 25.1] Now I want to extract the integer values ...
-4 votes
2 answers
237 views
Conversion of doubles to int [duplicate]
A project I have requires the movement of a player at a coordinate using getX and getY, however, I am confused on how to convert getX and getY from a double to an int so i can play them in the drawing ...
12 votes
8 answers
52k views
Best way to convert a double to String without decimal places
What is the best way to convert a double to String without decimal places? What about String.valueOf((int) documentNumber)? The doubles always have 0 after the decimal dot. I don't need to round or ...
3 votes
4 answers
8k views
Cast an Arraylist of Doubles to ArrayList of Integers
I am trying to convert an ArrayList to ArrayList. I am having actually a list of labels in Double and I want to create a list of Integers. I am trying to add the one to another but of course I need a ...
2 votes
5 answers
6k views
Remove digits which are in the decimal place
I get a double value (eg. -3.1234) which contains a value in decimals (0.1234 in this case). I want to remove the value in decimal value (in this case I wanted the value -3). How do I do it? I know ...
-1 votes
2 answers
2k views
Convert/Cast Double to int? (Object to primitive type)
How do I convert/cast a Double object to an int? Double d = new Double(12.34); int i = 12 //is what I'm looking for If I had a double I would just use: double z = 12.34; int i = (int)z; Note: I want ...
0 votes
3 answers
3k views
Remove decimals from a number shown in a TextView [duplicate]
For my simple calculator, I am showing the result in a TextView, but it is always showing decimals. How can I remove them ? This is my code : public class MainActivity extends Activity implements ...
1 vote
2 answers
443 views
Why cant we typecast Float(wrapper) to int(primitive) in java?
While I'm doing typecast from float to int type and typecast from Integer to int it is working. But while i am trying to typecast from Float to int type I'm getting the error as "incompatible type". ...
0 votes
3 answers
418 views
Get int from Vector of Objects
I use a method to get Data from a database and store it in a vector. The method will always return a Vector of Objects where the Object datatype can be either a Date, a Double or a String. In my case, ...
0 votes
3 answers
294 views
JPanel.setBounds(xx,xx,variable,xx) isn't working. why?
public void colortemperatureJSliderStateChanged(ChangeEvent event) { fahrenheitdegree = colortemperatureJSlider.getValue(); fahrenheitJPanel.setBounds(100,270, fahrenheitdegree, 20); ...
0 votes
2 answers
137 views
Parse CSV file to give values in ranges Java
I have a CSV file which has data on it such as: File % Diff testfile0.xml 44.948 testfile1.xml 22.232 testfile2.xml 45.343 testfile3.xml 2.345 testfile4.xml -3.948 testfile5.xml 22....