繁体   English   中英

在具有 void 返回类型的函数中返回字符串数组

[英]Returning String array in a function with void return type

关于上述问题,我不断收到错误消息。 请帮助..... 我必须在下周五之前将此代码作为我项目的一部分提交。 我在互联网上看过其他程序,但它们都使用缓冲区读取器,所以我无法理解。

void sports()
{
    
    String word, clue;
    
    <code related to initialization of word and clue>

    return String {word,clue};
}

}

请更改您的功能

void sports() {

    // Code 

        return String {word,clue};
    }

至:

String[] sports() {

        // Code 
        return new String[]{word, clue};
    }

这意味着您只需要更改函数sports 的返回类型并返回一个有效对象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM