java function的宣告方式如下圖:
如無回傳型能則使用void。使用return 內容,來回傳執行結果。

要呼叫使用此function method時,先(new 物件類別).方法名稱(傳入參數…)就可以了
![]()
在回傳型態前可以增加作用區域,而因為作用區域宣告的不同,可能會有無法取用的問題,這之後再詳述。

範例:
package yku;
public class TestFunction {
int max(int a,int b)
{
if(a>b)
return a;
else
return b;
}
public static void main(String args[]){
int val1 = 100;
int val2 = 200;
TestFunction fun = new TestFunction();
System.out.println(fun.max(val1, val2));
}
}
200
大大:
您好,我想請問一下
您之前有發一篇 [jsp]利用Google Map查詢經緯度
如果把這網頁的google map api改成v3版
要怎麼改?
下面呼叫API有一部分我看不懂要怎麼改@@
https://developers.google.com/maps/documentation/javascript/examples/?hl=zh-tw
您參考看看