Variable might not have been initialized error

前端 未结 11 1623
孤城傲影
孤城傲影 2020-11-21 05:50

When i try to compile this:

public static Rand searchCount (int[] x) 
{
    int a ; 
    int b ; 

    ...   

    for (int l= 0; l

        
11条回答
  •  Happy的楠姐
    2020-11-21 06:05

    You declared them at the start of the method, but you never initialized them. Initializing would be setting them equal to a value, such as:

    int a = 0;
    int b = 0;
    

提交回复
热议问题