简体   繁体   English

Eclipse在println方法上给出错误

[英]Eclipse giving error on a println method

Typing 打字

System.out.println("Hello world");

into eclipse gives error on the second "." 进入eclipse会在第二个"."上产生错误"." and on the ";" 并在";" .

The errror message looks like this: 错误消息如下所示:

Multiple markers at this line
    - Syntax error on token ".", @ expected after this token
    - Syntax error, insert "Identifier (" to complete 
     MethodHeaderName
    - Syntax error, insert ")" to complete MethodDeclaration
    - Syntax error, insert "SimpleName" to complete 
     QualifiedName

This has never happened before. 这从未发生过。 Mind you, this is happening on a computer where I just installed Eclipse and the newest JDK for x64 windows 10. Might have something to do with it, but I'm clueless. 请注意,这是在我刚刚安装了Eclipse和用于x64 Windows 10的最新JDK的计算机上发生的。可能与它有关,但我一无所知。

Thanks for any response! 感谢您的任何回复! :) :)

import java.util.Scanner;
public class Try
  {
    Scanner tastatur = new Scanner(System.in);
    double NOK = 1.0;
    double EUR = 9.34; 
    double USD = 8.46; 

 public static void Test(String args[]){
     System.out.println("");
  }
}

You can't use System.out.print() like that,you have to run it inside either a constructor or another method. 您不能像这样使用System.out.print(),必须在构造函数或其他方法中运行它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM