Java error “Value of local variable is not used”

后端 未结 7 1318
温柔的废话
温柔的废话 2020-12-06 18:00

I am really new to java (started learning 2 days ago). Sorry if this is a stupid question. I am trying to learn how to use rt.exec & similar methods so I tried to make a

7条回答
  •  时光说笑
    2020-12-06 18:34

    I believe what you have is not an error but a warning; eclipse (and other IDEs/compilers) will tell you that, although you assigned a value to the variable p, you did not use it anywhere. It tells you this because this is sometimes an error; mostly when you assign a value to a variable, you later use that variable in some way.

    You can eliminate the error by changing that particular statement to just

    rt.exec("calc.exe")
    

    since you are not required to assign a value from the call to exec.

提交回复
热议问题