在java中static 和void點解?

2006-10-14 7:36 am
在java中static 和void點解?

回答 (2)

2006-10-14 8:53 am
✔ 最佳答案
public static void main (String args[])

static 係指唔可以利用一個 instance method 去 override 一個 static 既 method.

void 係個 method 會 return 既 class type, void 代表唔會 return 任何野.

------------------

public void one_method ()
{
static int i;
...

呢個 static 係指 i 呢個整數只會嚮第一次行呢個 method 既時侯先會被 create 同 initialize.
當同一個 method 被執行第二次既時候就會用返第一次既 i, 而唔係重新 create 多另一個 i 出黎.
2006-10-14 1:06 pm
static applies to the whole class within that JVM, not an instance of a class.

static can be used in method, member variable etc.

void indicates the return type of the method. In this case, nothing is expected to be returned by the method.


收錄日期: 2021-04-29 23:31:06
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20061013000051KK05226

檢視 Wayback Machine 備份