Main.java:46: error: '.class' expected super.setPrice(float price); ^
时间: 2024-02-15 22:44:56 浏览: 119
This error is caused by the presence of the method call "super.setPrice(float price);" on line 46 of the Main.java file. The "super" keyword is used to call a method from the parent class, but it should be used only in a constructor and before any other statements. Here, it is used after the constructor and as a standalone statement, which is not allowed.
To fix this error, remove the "super." prefix and simply call the setPrice method from the current instance of the class, like this:
setPrice(price);
This will set the price of the current instance, without calling the parent class method.
阅读全文