[問題] 沒有宣告class保留字的類別

看板java作者 (watching you)時間8年前 (2017/03/21 10:59), 編輯推噓2(205)
留言7則, 6人參與, 最新討論串1/1
程式碼如下: import javax.ws.rs.core.Response; @GET @Produces({"application/json"}) public Response getSearchResults(@Context HttpServletRequest request) { String title = request.getParameter("title"); String type = request.getParameter("type"); return search(request, title, null, new String[] { type }); } 而關於Response的定義在https://tinyurl.com/oc8fyse 想請問一般的類別前面不是都會宣告class關鍵字嗎 這種前面只加修飾詞的用法是依據什麼? -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.124.165.66 ※ 文章網址: https://www.ptt.cc/bbs/java/M.1490065183.A.A8E.html

03/21 11:03, , 1F
這是方法吧
03/21 11:03, 1F

03/21 11:10, , 2F
這顯然是method,你怎麼會覺得是class?
03/21 11:10, 2F

03/21 11:35, , 3F
因為這只是一個回傳Response的方法 不是類別
03/21 11:35, 3F

03/21 12:00, , 4F
比較想知道你如何判定它為類別,想理解一下從哪開始出問題
03/21 12:00, 4F

03/31 09:02, , 5F
? 這是 method 吧
03/31 09:02, 5F

04/01 03:51, , 6F
因為 java 沒有 free function 然後這個方法剛好看起來
04/01 03:51, 6F

04/01 03:51, , 7F
像在 global scope 吧
04/01 03:51, 7F
文章代碼(AID): #1Oq9SVgE (java)
文章代碼(AID): #1Oq9SVgE (java)