以下代码给出了编译时错误:缺少返回值和缺少return语句,我将返回什么值Void Type?
final SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>()
{
@Override
protected Void doInBackground() throws Exception
{
// some code
if (something)
{
return;
}
}
}
Run Code Online (Sandbox Code Playgroud)
kos*_*osa 28
Void是不是void,将其更改为void类型,如果你不想返回任何东西.
Void是一个类,void是类型.
/**
* The {@code Void} class is an uninstantiable placeholder class to hold a
* reference to the {@code Class} object representing the Java keyword
* void.
*
* @author unascribed
* @since JDK1.1
*/
Run Code Online (Sandbox Code Playgroud)
如果需要Void,则需要return在结尾添加语句.
例:
protected Void doInBackground() throws Exception
{
// some code
if (something)
{
return null;
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6155 次 |
| 最近记录: |