“Variable may not have been initialized”

前端 未结 4 633
陌清茗
陌清茗 2020-12-22 02:42

I\'ve got a method that creates a String and another method that changes Strings

void create(){
    String s;
    edit(s);
    System.out.printl         


        
4条回答
  •  Happy的楠姐
    2020-12-22 03:15

    try to initialize the string "s" to a null value, since you have declared a variable "s" but it has not been initialized. Hence it can't pass the reference of that variable while used as parameter.

    String s = null;
    

    Hope this helps

提交回复
热议问题