我在我的 Macbook air OS 10.9 上使用 Eclipse for Java。我不断收到错误消息Obsolete Methods on the Stack,并警告说当我运行没有错误的非常基本的程序时它可能如何导致虚拟机出现问题。我运行了一个只有类和主要方法的程序,我得到了这个错误。在错误框之后,bug 提到了 main 方法,但我知道语法是正确的,因为我使用了 Eclipse 的 main 方法。
import java.util.Scanner; public class Dowhile { public static void main(String[] args) { /*Scanner scanner = new Scanner(System.in); System.out.println("Enter a number"); int value = scanner.nextInt(); System.out.println(value);*/ /*do{ System.out.println("Enter a number "); int value = scanner.nextInt(); } while(value != 5); System.out.println("Got 5");*/ } }
更新:我现在没有收到过时方法错误,只是Exception in thread “main”… at line 5.