Re: [問題] 關於內部類別的使用時機
看板java作者AmosYang (LetMeGoogleThatForYou)時間16年前 (2009/09/11 13:00)推噓3(3推 0噓 2→)留言5則, 4人參與討論串2/2 (看更多)
※ 引述《shengyu0932 (= =?)》之銘言:
: 如題 最近小弟在讀內部類別的時候分為四種
: 1.一般內部類別
: 2.方法類別
: 3.匿名類別
: 4.靜態內部類別
: 請問 當我們寫程式的時候 通常會在何種時機來用這四種方法?
: 謝謝
http://www.lmgtfy.com/?q=java+inner+class
2nd link: Inner classes - JavaWorld
http://www.javaworld.com/javaworld/javaqa/2000-03/02-qa-innerclass.html
Q: So what are inner classes good for anyway?
A: Believe it or not, there are advantages to Java's inner classes.
But before we go into that, I'll provide a short background on inner
classes.
Inner classes nest within other classes. A normal class is a direct
member of a package, a top-level class. Inner classes, which became
available with Java 1.1, come in four flavors:
Static member classes
Member classes
Local classes
Anonymous
Let's take a quick look at each in turn.
... 後略
--
"Mr. Data, can you show me how to parse this XML?"
"Certainly, sir. Let me google that for you."
-- StarTrek, the Next Gen. 《Back to 2009》 (誤)
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 65.87.177.87
→
09/11 13:04, , 1F
09/11 13:04, 1F
推
09/11 13:38, , 2F
09/11 13:38, 2F
推
09/11 20:30, , 3F
09/11 20:30, 3F
→
09/12 13:08, , 4F
09/12 13:08, 4F
推
09/12 20:26, , 5F
09/12 20:26, 5F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):