简体   繁体   English

如何修复编译错误:需要标识符

[英]How do I fix compilation error: identifier expected

I keep get error.How do I fix this?我一直收到错误。我该如何解决这个问题?

The error message is in the bottom.错误消息在底部。

Here is my code:这是我的代码:

public class AirTicketProcessor {

private ArrayList<AirTicket> airTickets 
    = new ArrayList<AirTicket>();
private ArrayList<AirTicket> airTicketsOriginal
    = new ArrayList<AirTicket>();
private ArrayList<String> invalidRecords
    = new ArrayList<String>();
 
public AirTicketProcessor() {
}

public void addAirTicket(AirTicket() tickets) {
 tickets = AirTicket().copyOf(tickets, tickets.length + 1);
 tickets[ticket.slength - 1] = newTicket; 
}
}

AirTicketProcessor.java:123: error: <identifier> expected
public void addAirTicket(AirTicket() tickets) {
                                  ^ 

The error you're getting means the code doesn't comply with the syntax rules of the Java language.您收到的错误意味着代码不符合 Java 语言的语法规则。

The syntax should be like this: public void addAirTicket(AirTicket tickets)语法应该是这样的: public void addAirTicket(AirTicket tickets)

By including the () after AirTickets , you are telling the compiler to invoke a function called AirTickets .通过在AirTickets之后包含() ,您是在告诉编译器调用一个名为AirTickets的函数。 It is not looking for a function call in the typing of your parameter list.它不是在输入参数列表时寻找函数调用。

You should be able to fix this error simply by removing the ()您应该能够通过删除()

Try: public void addAirTicket(AirTicket tickets) {试试: public void addAirTicket(AirTicket tickets) {

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

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