the error and the class http://puu.sh/1ITnS.png爪哇 - 「錯誤:無法找到或加載主類」錯誤
當我命名類文件Main.class,java的說,它的名稱有誤,當我將其命名爲shop.Main.class它說主要的課程無法找到。誰能幫忙?
package shop;
import java.text.DecimalFormat;
public class Main
{
public static void main(String args[])
{
Cart cart = new Cart(new Catalogue());
printOrder(cart);
}
public static void printOrder(Cart cart)
{
DecimalFormat df = new DecimalFormat("0.00");
System.out.println("Your order:");
for(int itemIndex = 0; itemIndex < cart.itemsInCart.products.size();
itemIndex++)
if (cart.itemsInCart.products.get(itemIndex).quantity != 0)
System.out.println(cart.itemsInCart.products.get(itemIndex).quantity
+ " " + cart.itemsInCart.products.get(itemIndex).name
+ " $"+ df.format(cart.itemsInCart.products.get(itemIndex).price)
+ " = $" + df.format
((cart.itemsInCart.products.get(itemIndex).quantity
* cart.itemsInCart.products.get(itemIndex).price)));
double subtotal = 0;
int taxPercent = 20;
double tax;
double total;
for(int itemIndex = 0; itemIndex < cart.itemsInCart.products.size();
itemIndex++)
subtotal += cart.itemsInCart.products.get(itemIndex).quantity
* cart.itemsInCart.products.get(itemIndex).price;
tax = subtotal * taxPercent/100;
total = subtotal + tax;
System.out.print("Subtotal: $" + df.format(subtotal)
+ " Tax @ " + taxPercent + "%: $" + df.format(tax)
+ " Grand Total: $" + df.format(total));
}
}
以下兩行之間忽略
-------------------------
編輯總結
糟糕!您的編輯無法提交,因爲:
您的帖子沒有太多的上下文來解釋代碼段;請更清楚地解釋你的情況。
取消
-------------------------
Java教程可以幫助
你的例子會工作。 –
顯示你的'main'代碼 – codeMan
要麼刪除'包店;從'java'文件夾 –