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

Edited by Varunkrishna

1 Year
Discussion Span
Last Post by Varunkrishna

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

Edited by Varunkrishna

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.