ArrayList marks = new ArrayList();
Double sum = 0.0;
sum = ((Double)marks.get(i));
Everytime I try to run my program, I get a ClassCastException th
Changing an integer to a double
int abc=12; //setting up integer "abc"
System.out.println((double)abc);
The code will output integer "abc" as a double, which means that it will display as "12.0". Notice how there is a decimal place, indicating that this precision digit has been stored.
Same with double if you want to change it back,
double number=13.94;
System.out.println((int)number);
This code will print on one line, "number" as an integer. The output will be "13". Notice that the value has not been rounded up, the data has actually been omitted.