gpt4 book ai didi

java - 尝试运行 Java 应用程序时出现 Eclipse 错误 - "Selection does not contain a main type"- 但确实如此?

转载 作者:行者123 更新时间:2023-12-01 23:44:19 25 4
gpt4 key购买 nike

我创建了一个 Java 包 Matrix。当我尝试运行它时,出现错误“选择不包含主类型”。但是,正如我从类 DriverMatrix 复制并粘贴的代码所示,有一个 main 方法声明。我尝试重新启动 Eclipse,但仍然收到错误消息。我创建了名为 Matrix 的包,然后为每个类导入了 .java 文件。有人知道这是怎么回事吗?这是主要声明以及一些代码:

package Matrix;

import java.io.*;
import java.util.Scanner;

public class DriverMatrix
{

static private IntegerArithmetics integerArithmetics = new IntegerArithmetics();
static private DoubleArithmetics doubleArithmetics = new DoubleArithmetics();

public static void main(String[] args) throws FileNotFoundException
{
Scanner inFile = new Scanner (new FileReader("in.txt"));
PrintWriter outFile = new PrintWriter("out.txt");

Matrix<Integer,IntegerArithmetics> matrix1 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix2 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix3 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix4 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,3);
Matrix<Integer,IntegerArithmetics> matrix5 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,3,2);
Matrix<Integer,IntegerArithmetics> matrix6 = new Matrix<Integer,IntegerArithmetics>(integerArithmetics,2,2);

最佳答案

您的项目中似乎存在 Matrix 类和包名称冲突,并且可能会导致 eclipse 错误。尝试重命名其中之一,然后运行您的应用程序。

关于java - 尝试运行 Java 应用程序时出现 Eclipse 错误 - "Selection does not contain a main type"- 但确实如此?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17386057/

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