• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot instantiate the type  RSS feed

 
Werner Holt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, all! I am trying to write thist method for my project and on line 10 i get the following error : "Cannot instantiate the type Speaker"
Can anybody help me with this?



 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is Speaker?
It looks like it is an interface or an abstract class.
If it is, you cannot instantiate it. you should instantiate a class extending Speaker or an implementation of Speaker interface instead.

A hint: your method would be better if it declared it returns List<Speaker> instead of ArrayList<Speaker>.
If you even feel a need to use different implementation of list, you would be free to do so without braking or changing your (or other people's) code.
 
Paramvir Phagura
Greenhorn
Posts: 7
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot create an object of "Speaker". Is it an interface? Is it an abstract class? Is the class's constructor private? Does it require use of a singleton to get ahold of? Does it consist of only static use methods?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!