gpt4 book ai didi

java - “Main method not found in class…”但它在那里?那为什么会出错呢?

转载 作者:行者123 更新时间:2023-12-02 11:06:55 26 4
gpt4 key购买 nike

我希望有人可以在这里为我提供帮助。我收到错误消息:

Main method not found in class Pythag, please define the main method as:

   public static void main(String[] args)


但是正如您在下面的代码中看到的那样,它在那里?那么为什么会出错呢?这似乎经常发生
到我在Eclipse Java EE IDE中的类。
public class Pythag {

// All Java applications have a main() method.
// This one does a simple Pythagorean calculation.
public static void main(String[] args) {

// Declare fields and initialise values(input).
int firstNum = 17;
int secondNum = 6;
int answer;

// Do the calculation (process).
//
answer = (firstNum * firstNum) + (secondNum * secondNum);

// Display the results (output).
//
System.out.println("The square of the hypotenuse is "
+ "equal to the sum of the squares "
+ "of the other two sides.");
System.out.println("For example...");
System.out.println(answer + " = " + firstNum + " squared + "
+ secondNum + " squared.");

}
}

最佳答案

我只是尝试验证我的代码,然后运行正常?不知道问题出在哪里还是为什么不起作用,但是验证代码似乎可以解决问题,所以我们去了?

关于java - “Main method not found in class…”但它在那里?那为什么会出错呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27710488/

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