| Author |
Problem with ArrayList toArray method
|
Brett Wiggins
Greenhorn
Joined: Mar 23, 2009
Posts: 19
|
|
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.
|
 |
Pramod P Deore
Ranch Hand
Joined: Jul 15, 2008
Posts: 629
|
|
is unitCode,unitTitle are String ? and type is courseType?
It will be easy if you show the code of constructor Unit(...)
|
Life is easy because we write the source code.....
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
|
Can you show us the constructors of your Unit class ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Brett Wiggins
Greenhorn
Joined: Mar 23, 2009
Posts: 19
|
|
|
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14685
|
|
|
what about Pramod's question ? is unitCode,unitTitle are String ? and type is unitType ?
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2818
|
|
|
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.
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2818
|
|
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.
|
 |
Brett Wiggins
Greenhorn
Joined: Mar 23, 2009
Posts: 19
|
|
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
|
 |
Brett Wiggins
Greenhorn
Joined: Mar 23, 2009
Posts: 19
|
|
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.
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2818
|
|
Wait, you're a noob? Crap. There goes the neighborhood...
|
 |
 |
|
|
subject: Problem with ArrayList toArray method
|
|
|