日期:2014-05-20  浏览次数:20670 次

麻烦各位大虾给具体解释下Void的用法?
如题,谢谢。

------解决方案--------------------
哎 百度搜搜啊 多的是啊......
笼统的说就是如果你想做某些操作 而且操作完后不需要返回任何值 那你就把方法定义成Void的
------解决方案--------------------
nothing more to say, 没有类型的时候用,在Java里,恐怕只有方法的返回值的地方可以用到了。
------解决方案--------------------
不会是想问java中方法的void修饰符吧...
------解决方案--------------------
java方法必须指定返回类型,如果你没有返回值,可以将其返回类型指定为void
------解决方案--------------------
Java code

//method that return String
public String method()
{
    //must return value of String type
    return new String( "..." );
}

//method that return int
public int method()
{
    //must return value of int type
    return digital;
}

//if here does not need to return any value
//then you can choose "void", means do not 
//need to "return"
public void method()
{
    //no word "return"
}

------解决方案--------------------
不需要返回值的方法的情况
------解决方案--------------------
void 不返回值 好像基础书上都有说吧