Hi guys why am I getting the error identifier expected at the package statement ? Here is my code.

package com.example.abstract;
public abstract class Car{
    private double price;
    private String color;
    private String year;
    private String model;
    abstract double accelerate();
    abstract double horsePower();
    public void setPrice(double price){
        this.price = price;
    }
    public double getPrice(){
        return price;
    }
    public void setColor(String color){
        this.color = color;
    }
    public String getColor(){
        return color;
    }
    public void setYear(String year){
        this.year = year;
    }
    public String getYear(){
        return year;
    }
    public void setModel(String model){
        this.model = model;
    }
    public String getModel(){
        return model;
    }


}

when I compile this class I get this error

javac comexampleabstractCar.java
comexampleabstractCar.java:1: error: <identifier> expected
package com.example.abstract;
                    ^
1 error

What is wrong here ?
Thanks
Varun Krishna. P

Edited 1 Year Ago by Varunkrishna

Got it package com.example.abstract; abstract is a key word in java, I can't name the package as abstract.

Edited 1 Year Ago by Varunkrishna

This question has already been answered. Start a new discussion instead.