V
V
V4kodin2021-12-06 06:06:34
Java
V4kodin, 2021-12-06 06:06:34

Error: Could not find or load main class how to fix?

abstract class Dish{


    public String size;
    public String color;



    public String getSize() { return size; }
    public String getColor() { return color; }

    public void setSize(String s) { size = s; }
    public void setColor(String c) { color = c; }

    public Dish(String s, String c) {
        this.size = s;
        this.color = c;
    }
    public abstract void displayInfo();
}

class Plate extends Dish{
    public String name = "Тарелка";

    public Plate(String size, String color) {
        super(size, color);
    }
    public void displayInfo(){
        System.out.println(" Название: " + name + " | Размер: " + super.getSize() + " | Цвет: " + super.getColor());
    }
}

class Cup extends Dish{
    public String name = "Кружка";

    public Cup(String size, String color) {
        super(size, color);
    }
    public void displayInfo(){
        System.out.println(" Название: " + name + " | Размер: " + super.getSize() + " | Цвет: " + super.getColor());
    }
}

class DeepPlate extends Dish{
    public String name = "Глубокая тареклка";

    public DeepPlate(String size, String color) {
        super(size, color);
    }
    public void displayInfo(){
        System.out.println(" Название: " + name + " | Размер: " + super.getSize() + " | Цвет: " + super.getColor());
    }
}

class TestDish {
    public static void main(String[] args) {
        Plate c1 = new Plate("Маленькая", "Белая");
        DeepPlate c2 = new DeepPlate("Маленькая", "Черная");
        Cup c3 = new Cup("Большая", "Розовая");
        c1.displayInfo();
        c2.displayInfo();
        c3.displayInfo();
    }
}


IntelliJ IDEA throws an error:
Error: Could not find or load main class Main
Caused by: java.lang.ClassNotFoundException: Main


I tried to rename the TestDish class to "Main", "main", file name. Still the same error.
There is exactly the same program (I literally copied, pasted, deleted some lines, replaced names) and it works fine. I do not understand what the problem is.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question