Specify your marks: List marks = new ArrayList() This is called generics.
Specify your marks: List marks = new ArrayList(); This is called generics.
If the ArrayList was full of Doubles then he would not get a ClassCastException. The array must be full of integers, right? – Gray Apr 6 at 12:32 @Gray - one Integer is enough ;) – Andreas_D Apr 6 at 12:55.
Well the code you've shown doesn't actually include adding any Integers to the ArrayList - but if you do know that you've got integers, you can use: sum = (double) ((Integer) marks. Get(i)).intValue(); That will convert it to an int, which can then be converted to double. You can't just cast directly between the boxed classes.
Note that if you can possibly use generics for your ArrayList, your code will be clearer.
We can cast an int to a double but we can't do the same with the wrapper classes Integer and Double: int a = 1; Integer be = 1; // inboxing, requires Java 1.5+ double c = (double) a; // OK Double d = (Double) b; // No way. This shows the compile time error that corresponds to your runtime exception.
Mysql gives on ClassCastException : java.math. BigInteger cannot be cast to java.lang.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.