2017-01-23 61 views
0

我使用了https://www.codingame.com的chrome插件(codin game Sync),将一个类下载到我的eclipse Version: Luna Service Release 2 (4.4.2)中。 Windows 8.1 Enteprise,这是一个非常简单的类:Eclipse不运行静态主类

class Player { 

    public static void main(String args[]) { 
     Scanner in = new Scanner(System.in); 
     int W = in.nextInt(); // width of the building. 
     int H = in.nextInt(); // height of the building. 
     int N = in.nextInt(); // maximum number of turns before game over. 
     int X0 = in.nextInt(); 
     int Y0 = in.nextInt(); 
     System.out.println("0 0"); 
     // game loop 
     while (true) { 
      String bombDir = in.next(); // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL) 

      // Write an action using System.out.println() 
      // To debug: System.err.println("Debug messages..."); 


      // the location of the next window Batman should jump to. 
      System.out.println("0 0"); 
     } 
    } 
} 

但它从来没有任何打印到我的控制台。

点:

我用的类添加到构建路径,但它仍然无法打印任何东西,但它运行的项目。

右键单击项目 - >属性 - > Java构建路径 - >选项卡源 - >选择项目名称/ src目录/ main-> Java的

只有一个,标签上的域开放codin.com

+5

这是用'System.in'扫描你的一些输入。你提供任何?你需要提供5个整数作为输入。 –

+0

尝试Ctrl + F11为您的java程序! – Darshit

+0

它适合我。你在控制台输入什么东西?否则,in.m'nextInt()将永远等待。 – GAlexMES

回答

0

我怀疑你的应用工作,但你不知道它:) 这样做:

Scanner in = new Scanner(System.in); 
    System.out.println("Hello App"); 
    int W = in.nextInt(); // width of the building. 
    int H = in.nextInt(); // height of the building. 
    int N = in.nextInt(); // maximum number of turns before game over. 
    int X0 = in.nextInt(); 
    int Y0 = in.nextInt(); 
    System.out.println("0 0"); 

如果您在控制台中看到消息“你好应用程序”然后应用程序被运行刚刚WA希望你输入一些ints ..

+1

为了完成你的答案,当然这是有效的。 'CodinGame'只需要使用输入来编写算法,它会在'run'点击时自动提供一个输入列表。这里,在eclipse上,这些输入来自用户,OP可能没有得到。 – AxelH