S
S
SandPie2021-07-24 21:15:13
Java
SandPie, 2021-07-24 21:15:13

I don’t understand where the missing return statement error comes from, where is it and what does it consist of?

I read about this error, but still I can not understand why I get this error.

public class Praktikum {

    public static void main(String[] args) {
        findHighestGrossingFilm();
        String highestGrossingFilm = findHighestGrossingFilm();
        System.out.println("Самый кассовый фильм: " + highestGrossingFilm);
    }

    public static String findHighestGrossingFilm() {
        String film1 = "Титаник";
        int income1 = 2194;

        String film2 = "Аватар";
        int income2 = 2810;

        String film3 = "Тёмный рыцарь";
        int income3 = 1084;

    }
    public static String findHighestGrossingFilm(int income1, int income2, int income3, String film1, String film2, String film3) {
        String film;
        if (income1 > income2 & income1 > income3) {
           film = film1;
        } else if (income2 > income1 & income2 > income3) {
            film = film2;
        } else {
            film = film3;
        }
        return film;
        }
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2021-07-24
@SandPie

Seriously? Do you have a "missing return statement" error, are you looking at a method that is declared to return a String that does not have a single return statement, and still do not understand what the problem is?

D
Disis, 2021-11-15
@Disis

public class Praktikum {
public static void main(String[] args) {
String highestGrossingFilm = findHighestGrossingFilm();
System.out.println("Highest Grossing Film: " + highestGrossingFilm);
}
public static String findHighestGrossingFilm() {
String film1 = "Titanic";
int income1 = 2194;
String film2 = "Avatar";
int income2 = 2810;
String film3 = "The Dark Knight";
int income3 = 1084;
if (income1 > income2 & income1 > income3) {
return film1;
} else if (income2 > income1 & income2 >
} else {
return film3;
}
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question