error: variable might not have been initialized & if statement

后端 未结 4 497
一生所求
一生所求 2020-12-04 01:32

So basically, the

 //Black ops 2 Class generator Please help me FIX!!!!!!
    import java.util.Scanner;
    import java.util.Random;
    public class money
         


        
4条回答
  •  执念已碎
    2020-12-04 02:05

    It say's im not initializing the variable but I initialize it in the last if statement

    What happens if that "if" block is not executed? Then that variable will be un-assigned right? That is why compiler complaining.

    Local variable should be assigned in all possible flows, otherwise it is compiletime error.

提交回复
热议问题