• + 10 comments

    I am facing an error "MyBook.java:35: error: class Solution is public, should be declared in a file named Solution.java public class Solution ^ 1 error"

    why? and is the code right?

    Code:

    public class MyBook extends Book {int p;

     MyBook(String title,String author,int price)
        {
         super(title,author);
    
         this.p=price;
    
    }
    void display()
        {
        System.out.println("Title: "+title);
        System.out.println("Author: "+author);
        System.out.println("Price: "+p);
    }
    

    }