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 ?
Varun Krishna. P

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.