Cannot Instantiate the Type List<Product>

Cannot instantiate the type ListProduct

List is an interface. Interfaces cannot be instantiated. Only concrete types can be instantiated. You probably want to use an ArrayList, which is an implementation of the List interface.

List<Product> products = new ArrayList<Product>();

Java returns error Cannot instantiate the type

Car is an Abstract class you cannot create an instance of it.

public abstract class Car implements Automobile

you can potentially do something like

public class FordFocus extends Car 

keep in mind that you will need to call the super constructor, but then you will be able to create an instance of the FordFocus car type

cannot instantiate type of array list

You don't seem to be comparing String(s) correctly, and you can't instantiate an abstract class. Options1,

  1. Remove abstract from Antenna, or
  2. Create a concrete subclass and instantiate that subclass

Something like

if (tip.equals("K")) { // == "K"){
Antenna nova = new Antenna(Integer.parseInt(delovi[1].trim()), // ...

And remember to then change "Antena" like

public class Antenna { // <-- Not abstract

1I have also corrected the spelling of antenna.

Cannot instantiate the type

You cannot instantiate Interface List with new List()

The keyword new is for creating (instantiating) object. In this case, you can instantiate Interface List with any class that implements List

mUsers = new ArrayList<ParseUser>(); //example with ArrayList

See All Known Implementing Classes: of List in Java api here.



Related Topics



Leave a reply



Submit