为什么要有内部类?

  An inner class is a class that is defined inside another class. Why would you want to do that? There are three reasons:

• Inner class methods can access the data from the scope in which they are defined—including the data that would otherwise be private.

• Inner classes can be hidden from other classes in the same package.

• Anonymous inner classes are handy when you want to define callbacks without writing a lot of code.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,452评论 0 10
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 9,959评论 0 23
  • 我在大洋的一边,望着看不见的彼岸 你在冬天的雪光中,想烤出夏天的温暖 他幻想有一双翅膀飞跃海的宽和时光的長 于是我...
    江上渔夫阅读 196评论 0 0
  • 请人吃早饭的梁实秋 文/石岩磊 梁实秋是我国近代著名文学家,他的生活非常有规律,每天晚上八点休息,第二天早上四点起...
    石岩磊简书阅读 715评论 2 3
  • 坐上北上的火车,来回奔波与两个城市之间已成常态,对小姨的留恋总是那么多~吃饭之间喝了小酒,导致赶车时间紧张,...
    胡晓梅阅读 187评论 0 0