Java - IntelliJ抱怨错过了分号,但我不确定是什么问题

时间:2017-05-31 18:20:53

标签: java intellij-idea

我在做Udemy Java课程时遇到了问题。我已经编写了下面的代码,因为课程的主题是方法。 Hoverer,我不知道为什么它不能被编译。有人可以帮我发现错误吗?

这是IntelliJ给我的错误:

List of errors

public class Main {

public static void main(String[] args) {

    String playerName = "Piotr";

    int playerPosition = CalculateHighScorePosition(1500);
    displayHighScorePosition("Piotr", playerPosition);

    playerPosition = CalculateHighScorePosition(900);
    displayHighScorePosition("Cezary", playerPosition);

    playerPosition = CalculateHighScorePosition(400);
    displayHighScorePosition("Adam", playerPosition);

    playerPosition = CalculateHighScorePosition(50);
    displayHighScorePosition("Julia", playerPosition);

    private static void displayHighScorePosition(String playerName, int playerPosition) {
    System.out.println( playerName + " managed to get into " + playerPosition );

}

    private static int CalculateHighScorePosition(int playerScore) {
        if (playerScore > 1000) {
            return 1;
        }
        else if (playerScore > 500 && playerScore < 1000) {
            return 2;
        }
        else if (playerScore > 100 && playerScore < 500) {
            return 3;
        }
        else {
            return 4;
        }
    }

}
}

1 个答案:

答案 0 :(得分:2)

尽管我有更好的判断力,但我正在回答这个问题。

您已在main方法中定义了两种方法。

  button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
    String lat1 = sLatitude1.getText().toString();
    // parse string to double
    lati1 = ParseDouble(lat1);
    String lon1 = sLongtiude1.getText().toString();
    longi1 = ParseDouble(lon1);
    String lat2 = dLatitude2.getText().toString();
    lati2 = ParseDouble(lat2);
    String lon2 = dLongtiude2.getText().toString();
    longi2 = ParseDouble(lon2);
            double xy1 = distanceBetween(new LatLng(lati1, longi1), new LatLng(lati2, longi2));
            String distanceis = fmt(xy1) + "meter";
            textView.setText(distanceis);
        }

    });