Почему если описать функцию таким образом компилятор ругается?
public static double getWeight(int weightEarth) {
return double weightMoon = weightEarth * 0.17;
}
А таким нет:
public static double getWeight(int weightEarth) {
double weightMoon = weightEarth * 0.17;
return weightMoon;
}
package com.javarush.task.task01.task0136;
/*
Да хоть на Луну!
*/
public class Solution {
public static void main(String[] args) {
System.out.println(getWeight(888));
}
public static double getWeight(int weightEarth) {
double weightMoon = weightEarth * 0.17;
return weightMoon;
}
}