Java - Missing return statement

后端 未结 3 599
南方客
南方客 2021-01-29 10:01

I get an error - \"missing return statement\" - on line 26, which in this case is the last curly bracket in the code. I know that it literally means that I have to return somewh

3条回答
  •  孤城傲影
    2021-01-29 10:25

    public String[] OpenFile() // expected return type is String array
    

    But you didn't return that from your method.

    If you don't want to return that change your method return type to void(no return)

    public void OpenFile() throws IOException {
    
    }
    

    Or if you want to return as expected use

    public String[] OpenFile() throws IOException {
    
     String[] arr=new String[5];
    
     // implementation
    
     return arr; 
    

    }

提交回复
热议问题