源代码是这样滴/*7. 定义一个Bank类实现银行帐户的概念,包括的变量有"帐号"和"存款余额",包括的方法有"存款"、"取款"和"查询余额"。定义主类,创建帐户类的对象,并完成相应操作。(此题必做)
提示:
 Bank类包括私有数据成员top(标记当前帐位置,即处理存入和取出的总次数)、date(日期)、money(金额)、rest(余额);
另有一个构造函数(初始化数据成员)和三个成员方法bank()(处理存入帐),bankout()(处理取出帐)和disp()(输入明细帐);
 日期使用字符串组用来存放操作日期;金额和余额使用整型数组。
 输出时将三个数组中的第i个元素在一行输出。
输出结果: 
  日期           存入          取出          余额 
98/07/12    2000          
98/07/15           1800    200
*/
import java.util.*;
public class Test { public static void main(String[] args) {
Bank bank = new Bank("55555",0,0);
bank.disp();
}}class Bank{
String id;
int[] rest = new int[5];
String[] date = new String[5];//最多可以存5个日期,如何变得更灵活???
int[] money = new int[5];
private int top;

Bank(String id, int rest, int money){
this.id = id;
this.money[top] = money;
this.rest[top] = rest;
top++;
}

Bank(String id){
this.id = id;
this.money[top] = 0;
this.rest[top] = 0;
top++;
}

void bank(int money){//处理存入账
this.money[top] = this.money[top - 1] + money;
rest[top] = this.money[top]; 
top++;
}

void bankout(int money){//处理取出账
this.money[top] = this.money[top - 1] - money;
rest[top] = this.money[top]; 
top++;
}

void disp(){//输入明细账
Scanner read = new Scanner(System.in);
System.out.println("请输入日期(xx/xx/xx)");

date[top] = read.next();//如何把日期存到对应的数组单元里???

System.out.println("\"存款\"请输入:1\t\"取款\"请输入:-1");
int flag = read.nextInt();

switch(flag){
case 1: System.out.println("请输入金额:"); bank(read.nextInt()); break;
case -1: System.out.println("请输入金额:"); bankout(read.nextInt()); break;
}
}

public void printMyMessage(){
System.out.println("日期\t" + "存入\t" + "取出\t" + "余额");
for(int i = 1; i < top; i++){
System.out.print(date[i] + "\t");
System.out.print(money[i] - money[i - 1] + "\t");
}
}
}
错误提示:
java.lang.NoSuchMethodError: main
Exception in thread "main" 

解决方案 »

  1.   

    你的eclipse的JRE路径配置不对
    go to windows->perference->java->installed JRE
    then select proper JDK directory
      

  2.   

    String[] date = new String[5];//最多可以存5个日期,如何变得更灵活???
    用list
    List<String> date=new ArrayList<String>();
      

  3.   

    编译问题 说明楼主的这个类没有编译 看看你的IDE中的JRE路径配置和JDK的版本是不是正确的
      

  4.   

    如果是命令行编译运行,可能是JDK 版本不对
    如果是Eclipse,可能是Eclipse的JDK配置不正确,或者JDK的路径里有空格。 把JDK移动到一个没有空格的路径下,然后重新配置Eclipse的JRE