0

Variable might not have been initialized

Why do I get an error like this: "result" might not have been initialized. import java.util.Scanner; public class gyak { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int a = scanner.nextInt(); int result; for (int i=a-1;i>=1;i--){ result= a*i; } System.out.println(result); } }

16th Jun 2018, 7:01 PM
Adam
Adam - avatar
1 Réponse
+ 2
yes :) in the meantime I found it out vut thanks for helping ;)
16th Jun 2018, 7:16 PM
Adam
Adam - avatar