跳轉至內容

Java 程式設計/關鍵詞/void

來自 Wikibooks,開放世界中的開放書籍

void 是一個 Java 關鍵字。

在方法宣告和定義中使用,用於指定該方法不返回任何型別,該方法返回 void。它不是一種型別,也沒有 void 引用/指標,如在 C/C++ 中。

例如

Computer code
public void method()
 {
   //...
   return;   // -- In this case the return is optional
//and not necessary to use public but some changes will be there
 }

參見

華夏公益教科書