This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Error while passing List as a parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error while passing List as a parameter" Watch "Error while passing List as a parameter" New topic

Error while passing List as a parameter

Arun R. S. Chandran
Ranch Hand

Joined: Oct 08, 2008
Posts: 81

In my class I am using list to store some calculated result.

For this I am collecting data from DB and storing into a list object.
the declaration of the List is given below

List<GuageReportdata> values2 = new ArrayList<GuageReportdata>();

The List is declared in the type of another class GuageReportdata.
And I am using a methode-----

public List<GuageReportdata> addResultdataofLathe(ArrayList<GuageReportdata> values , int size ) {


But when I am calling the method and passing the list it's showing ERROR:
" Type mismatch: cannot convert from List<GuageReportdata> to ArrayList<GuageReportdata> "

I am calling the methode inthis way
List<GuageReportdata> result = addResultdataofLathe( values1, values1.size());

Please help me to find out where I made a mistake.

Reinhard Horn
Ranch Hand

Joined: Jun 04, 2007
Posts: 31
Hi Arun,

try to change the type of your input param from ArrayList to List.


Arun R. S. Chandran
Ranch Hand

Joined: Oct 08, 2008
Posts: 81
Thank you for your kind advice, thank you very much.

I tried but that also throwing some error.

Actually the problem was with the return type of method.
Actually the method returns a value of type List.
But the receiving end "result" is declared as ArrayList.

Actually it was the problem.
But I didn't notice that.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Error while passing List as a parameter
jQuery in Action, 3rd edition