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,
- Remove
abstract
fromAntenna
, or - 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
How to Update Maven Repository in Eclipse
Reverse Java Graphics2D Scaled and Rotated Coordinates
Comparing Date Strings in Java
Fetch First Element of Stream Matching the Criteria
How to Escape the Equals Sign in Properties Files
How to Change the Color of Titlebar in Jframe
Files.Walk(), Calculate Total Size
A Rotated Square Panel in Java Gui
Java 8 Streams - Collect VS Reduce
Binding a List in @Requestparam
Java "" Operator for Checking Null - What Is It? (Not Ternary!)
09 Is Not Recognized Where as 9 Is Recognized
How to Use Sqoop in Java Program
How to Find Out If "Debug Mode" Is Enabled
Performance Difference Between Java 8 Lambdas and Anonymous Inner Classes
Preparedstatement Syntax Error
Converting String to Date Using Simpledateformat Is Returning Random Date