error: variable might not have been initialized & if statement

后端 未结 4 494
一生所求
一生所求 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 01:59

    You have to initialize the variable before you use it. If if statement fails, this variable will stay uninitialized:

     System.out.println("Primary Weapon: " + primaryWeapon); 
    

    So, where you declare it, equal it to "":

    String primaryWeapon = ""; //The gun you get
    

提交回复
热议问题