gpt4 book ai didi

java - Eclipse Java 启动错误 : Selection does not contain a main type

转载 作者:行者123 更新时间:2023-12-01 14:48:05 26 4
gpt4 key购买 nike

这是我的第一个 java 程序,我尝试在 Eclipse 和 Netbeans 中启动它。我收到启动错误:“选择不包含主要类型。”我的主要功能的代码如下。完整代码可以从http://www.fractalwebdesigns.com/classes.java下载

    class test {
public static void main(String[] args) {

//Checking Account Test
CheckingAccount checking1 = new CheckingAccount();
CheckingAccount checking2 = new CheckingAccount();
CheckingAccount checking3 = new CheckingAccount();
CheckingAccount checking4 = new CheckingAccount();

checking1.open(1234); //Open a checking account with an account number 1234
checking2.open(1235); //Open a checking account with an account number 1235
checking3.open(1236); //Open a checking account with an account number 1236
checking4.open(1237); //Open a checking account with an account number 1237
checking1.credit(3000); //Credit 3000 to the account 1234
checking2.credit(200); //Credit 200 to the account 1235
checking3.credit(5000); //Credit 5000 to the account 1236
checking4.credit(2000); //Credit 2000 to the account 1237
checking1.debit(500); //Debit 500 from the account 1234
checking3.debit(300); //Debit 300 from the account 1236
checking4.debit(2500); //Debit 2500 from the account 1237
checking1.readBalance(); //Read the balance of the account 1234
checking2.readBalance(); //Read the balance of the account 1235
checking1.readLastDepositAmount(); //Read last deposit amount of the account 1234
checking4.readLastDepositAmount(); //Read last deposit amount of the account 1237

//Saving Account Test
SavingsAccount savings1= new SavingsAccount();
SavingsAccount savings2= new SavingsAccount();
SavingsAccount savings3= new SavingsAccount();
SavingsAccount savings4= new SavingsAccount();

savings1.open(5431); //Open a savings account with an account number 5431
savings2.open(5432); //Open a savings account with an account number 5432
savings3.open(5433); //Open a savings account with an account number 5433
savings4.open(5434); //Open a savings account with an account number 5434
savings1.credit(2000); //Credit 2000 to the account 5431
savings2.credit(4000); //Credit 4000 to the account 5432
savings3.credit(1000); //Credit 1000 to the account 5433
savings4.credit(5000); //Credit 5000 to the account 5434
savings3.debit(2000); //Debit 2000 from the account 5433
savings2.credit(1000); //Credit 1000 to the account 5432
savings2.debit(2000); //Debit 2000 from the account 5432
savings2.debit(500); //Debit 500 from the account 5432
savings2.debit(300); //Debit 300 from the account 5432
savings2.debit(600); //Debit 600 from the account 5432
savings2.debit(100); //Debit 100 from the account 5432
savings2.readBalance(); //Read the balance of account 5432
savings1.addInterest(.1); //Add interest to the account 5431 with the interest rate 10%
savings2.addInterest(.1); //Add interest to the account 5432 with the interest rate 10%
savings3.addInterest(.1); //Add interest to the account 5433 with the interest rate 10%
savings2.readCumulativeInterest(); //Read the cumulative interest of the account 5432
savings2.readBalance(); //Read the balance of account 5432.
}
}

最佳答案

这是一个什么样的项目?它应该是一个Java项目。来源文件还应该位于项目的 Java 构建路径的源文件夹中。我还建议不要使用“默认”包。

关于java - Eclipse Java 启动错误 : Selection does not contain a main type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15194804/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com