Forums Register Login

Problem with ArrayList toArray method

+Pie Number of slices to send: Send
Hi,

I am having some problems getting an array from an ArrayList. My code is as follows;



That seems to be fine but when I try and use the array as a constructor argument;



I get;



any help would be cool.
+Pie Number of slices to send: Send
is unitCode,unitTitle are String ? and type is courseType?

It will be easy if you show the code of constructor Unit(...)
+Pie Number of slices to send: Send
Can you show us the constructors of your Unit class ?
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
what about Pramod's question ? is unitCode,unitTitle are String ? and type is unitType ?
+Pie Number of slices to send: Send
Looks like the problem is in the third parameter. The constructor expects the third parameter to be a unitType, but you're trying to pass in a courseType.
+Pie Number of slices to send: Send
The types that the constructor expects were defined in the constructor, just shown. The types that were being passed in were revealed in the error message:

This tells us it's looking for a Unit constructor that takes (String, String, courseType, Campus[]), but it can't find that combination.

By the way, it's generally a bad idea to have class names that begin with lowercase letters. They defy well-established standard convention. The compiler doesn't care, but such names tend to mislead the humans who look at your code and try to help you. Class names are expected to begin in uppercase; variable names begin with lowercase.
+Pie Number of slices to send: Send
 

Pramod P Deore wrote:is unitCode,unitTitle are String ? and type is courseType?

It will be easy if you show the code of constructor Unit(...)



they are Strings', the type and CourseType refer to enums. Thankyou for your help. I have fixed the problem
+Pie Number of slices to send: Send
Thanks for all the help. I had two different enums. unitType and courseType. I have replaced the two enums with just one and it has worked
like magic and fixed the problem. Everyone here seems to be noob friendly.
+Pie Number of slices to send: Send
Wait, you're a noob? Crap. There goes the neighborhood...
mooooooo ..... tiny ad ....
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2251 times.
Similar Threads
Java Object Oriented Grades Program
constructor to add to an array list
How can I use abstract class methods
problem about constructing Integer objects
cant find constructor in packaged jar
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:44:24.