我的 Java 简单代码有一些问题。我想做飞机航班搜索程序,但是当我将变量保留在参数下时,出现错误:
Airlines.java:14: error: int cannot be dereferenced
String Parameters = flightNumber_go.getParameters();
任何人都知道我如何解决这个问题?
附言。对不起,我的英语不好
import java.util.Scanner;
class Airlines{
public static void main(String args[]) throws Exception{
Flight 524 = new Flight("Moskwa", "Londyn", 140);
Flight 135 = new Flight("Warszawa", "Wroclaw", 60);
Flight 141 = new Flight("Frankfurt", "Rzym", 95);
Scanner flightNumber = new Scanner(System.in);
System.out.println("Enter code of your flight: ");
int flightNumber_go = Integer.valueOf(flightNumber.nextLine());
String Parameters = flightNumber_go.getParameters();
System.out.println(Parameters);
}
}
class Flight{
String departures;
String arrival;
int price;
public Flight(String departures, String arrival, int price){
this.departures = departures;
this.arrival = arrival;
this.price = price;
}
public String getParameters(String ... args){
return "Lot z "+this.departures+" do "+this.arrival+" kosztuje "+this.price;
}
}
皈依舞
相关分类