aspose file tools*
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
Author

Error while passing List as a parameter

Arun R. S. Chandran
Ranch Hand

Joined: Oct 08, 2008
Posts: 81
Friends,

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.

-ARUN
:roll:
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.



Regards


SCJP 5, SCWCD 1.4, SCBCD 5
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.


-ARUN
 
jQuery in Action, 2nd edition
 
subject: Error while passing List as a parameter