I am manually converting code from Java (1.6) to C# and finding some difficulty with the behaviour of primitives (int and double). In C# it appears that almost all conversions happen automatically
List<double> list1 = new List<double>(); // legal, C#
double d0 = 3.0;
list1.Add(d0); // legal, C#
Double dd = 2.3f; // legal, C#
list1.Add(dd); // legal, C#
List<Double> list2 = new List<Double>(); // legal, C#
double d1 = 3.0;
list2.Add(d1); // legal, C#
list2.Add(2.0); // legal, C#
double d2 = list2.get(0); // legal, C#
but in Java only some are allowed
List<double> list1 = new ArrayList<double>(); // illegal, Java
List<Double> list2 = new ArrayList<Double>(); // legal, Java
double d1 = 3.0;
list2.add(d1); // legal, Java
list2.add(2.0); // legal, Java
double d2 = list2.get(0); // legal, Java
I'd be grateful for a systematic analysis of the differences and any underlying rationale.