Ok. Easy!
Lets go over what you need to do.
1) You need to accept user input, a number in this case and you need to store that in a ArrayList.
Lesson1 : While defining ArrayList references, you need to specify that type of the values that the ArrayList can contain(lets forget about the "generic" type for now). You can create ArrayLists of type Integer, Float, Double, Object...etc. When you create an ArrayList of type X, you can only put in values of type X into it. If you break this rule, compiler will throw up an error. Ok?
Now, corresponding to my first point in previous post, what you have done is created an ArrayList of type ArryMathOps_2. Now in such a list, you can only store elements of type ArryMathOps_2. But what you really need, is to create an ArrayList of Double and put in values of Double. Here aValue can be Double or a double because of a concept called
Autoboxing. The compiler will automatically convert a plain double literal to an object Double and store it into the list. You are right in saying that ArrayList can contain only objects and not plain literals.
Now I presume that you know what type of ArrayList needs to be created.
2) Next, you need to loop 10 times, accept the double value in each loop and store that value in the ArrayList of Double.
Lesson2 : ArrayList API says that it has 2 basic add methods. One which requires an index and one that doesn't.
public boolean add(E e)
Appends the specified element to the end of this list.
and
public void add(int index, E element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
You are using the second case. You have the index "i" which ranges from 0 to 9 and you have the element namely the double value aValue.
So essentially your add call should be like arry1.add(i, aValue); Right? Line 17 is of no use.
3) Now for the final step. The arry1 ArrayList of Double needs to be assigned to a member variable(arrayData) in the class ArryMathOps_2 and we have a constructor to do just that. The constructor is defined as below,
Now if you've followed the change in step 1 properly, the line
should not throw an error. Why? Because the constructor is looking for a ArrayList<Double> and arry1 would also be an ArrayList<Double>. This should essentially solve your errors and you should be able to run it smoothly.
I suggest you go through the nuts and bolts of
Generics and then try solving the problem. Good luck!