简体   繁体   English

<identifier>使用搜索对象时出现预期错误

[英]<identifier> expected error when using a Search object

what is the solution of this error 这个错误的解决方案是什么?

public static void main(String[]args){

  Scanner in = new Scanner(System.in);
  String KeySearch = in.nextLine();
  Search obj = new Search(KeySearch."list.txt");
  obj.ReadFile();
  obj.ShowPrice();
}

C:\Users\jody\Desktop\Search.java:67: error: <identifier> expected
      Search obj = new Search(KeySearch."list.txt");
                                        ^
C:\Users\jody\Desktop\Search.java:67: error: ';' expected
      Search obj = new Search(KeySearch."list.txt");

I suspect you meant to use a comma instead of a period. 怀疑你的意思是使用逗号而不是句号。 A comma would separate two arguments, whereas what you have right now is not syntactically valid. 逗号会分隔两个参数,而您现在拥有的参数在语法上并不合法。

You might have meant to concatenate the KeySearch string with "line.txt", in which case you need to use + rather than a period. 您可能打算将KeySearch字符串与“line.txt”连接起来,在这种情况下,您需要使用+而不是句点。 This can happen if you have your PHP hat on :) 如果你有你的PHP帽子,这可能会发生:)

Search obj = new Search(KeySearch + "list.txt");

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

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