作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我创建了一个 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/
我是一名优秀的程序员,十分优秀!