• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with ArrayList toArray method

 
Brett Wiggins
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is unitCode,unitTitle are String ? and type is courseType?

It will be easy if you show the code of constructor Unit(...)
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show us the constructors of your Unit class ?
 
Brett Wiggins
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about Pramod's question ? is unitCode,unitTitle are String ? and type is unitType ?
 
Mike Simmons
Ranch Hand
Posts: 3028
10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3028
10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3028
10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait, you're a noob? Crap. There goes the neighborhood...
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic