gpt4 book ai didi

java - 错误 : Main method not found in class MovieDatabase

转载 作者:行者123 更新时间:2023-11-30 11:08:20 25 4
gpt4 key购买 nike

错误:在 MovieDatabase 类中找不到 Main 方法,请将 main 方法定义为:public static void main(String[] args) 或 JavaFX 应用程序类必须扩展 javafx.application.Application

import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Arrays;

public class MovieDatabase {
private int[] analysis;

//creating the contructor
public MovieDatabase(String file){
analysis = new int[2015];

this.load(file);
}
//uses the load(String file) method from downstairs to do all of the work


public void load(String file){
Scanner theScanner = null;

try{
//inputing the into the scanner
theScanner = new Scanner(new FileInputStream(file));
}
catch(Exception ex){
ex.printStackTrace();
}
// as long as the scanner has another line
while(theScanner.hasNextLine())
{
String Line = theScanner.nextLine();
//make an array called split and allocated different elements based on a seperation of ##
String split[] = Line.split("##");
int year = Integer.valueOf(split[1]);
analysis[year] ++;
}

}

//print out the array in the synchronous format
public void print(){
System.out.printf("%1$-30s %2$10s %3$10s %4$10s ", "Year", "Occurances", "", "");
//go through the array
for (int i =0;i < analysis.length ;i++ ) {
if(analysis[i] >0){
for (int j =i;j < analysis.length ;i++ ){
System.out.printf("%1$-30s %2$10s %3$10s %4$10s ", j, analysis[j], "", "");
}
}
}
}
}

如何修复此错误消息?我读过其他类似的问题,但只是说要公开类(class)。我的是公开的。

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