Because subAmount
is not declared as static
, it must be initialized at the time of declaration. So you should have something like this
import java.util.Scanner;
public class OnlineShop {
public static void main (String[]args) {
final double subAmmount = Array[i]; // Assuming Array[i] is defined somewhere
}
If you'd like to do declaration followed by initialization, you'd do:
import java.util.Scanner;
public class OnlineShop {
static final double subAmmount;
public static void main (String[]args) {
subAmmount = Array[i]; // Assuming Array[i] is defined somewhere
}
Checkout this link for more nuances on the final
keyword