Java error “Value of local variable is not used”

后端 未结 7 1316
温柔的废话
温柔的废话 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:43

    The use of the variable is not in issue here. That error appears because JVM needs a method with the signature to know where to start execution.

    public static void main( String args[] ){ //TODO: Stuff here } 
    

    Introduce a method with this signature in your class, and it shall clear that error. Alternatively, you may embed your code in a static block as below - but this method is not to be recommended.

    static {
        // TODO: Your code here
    }
    

提交回复
热议问题