SlideShare a Scribd company logo
1 of 6
Download to read offline
北京圣思园科技有限公司
http://www.shengsiyuan.com
Group related classes and thus reduce
namespace clutter
defined at a scope smaller than a package
An inner class can be defined inside another
class, inside a method, and even as part of
an expression
There are four types of inner classes
• static inner classes (also called nested classes)
• member inner classes
• local inner classes
• anonymous inner classes
The simplest form of inner class
Can’t have the same name as the enclosing
class
Compiled into a completely separate .class
file from the outer class
Can access only static members and
methods of the enclosing class, including
private static members
Create an instance of a static inner class out
of enclosing class:
• new outerclass.innerclass()
 Defined in an enclosing class without using the static
modifier
 Like instance variables
 Can access all members of the enclosing class
 Create an instance within the enclosing class
this.new Innerclass();
 Create an instance out of the enclosing class
(new Outerclass()).new Innerclass();
 Access members of the enclosing class within inner
classes
Outerclass.this.member
Defined within the scope of a method, even
smaller blocks within methods
The least used form of inner class
Like local variables, can’t be declared public,
protected, private and static
Can only access final local variables
Local inner classes which don’t have class names
No key word class
No key word extends and implements
No constructors
Implicitly extend a superclass or implement an
interface

More Related Content

What's hot (16)

Inner Classes in Java
Inner Classes in JavaInner Classes in Java
Inner Classes in Java
 
Java- Nested Classes
Java- Nested ClassesJava- Nested Classes
Java- Nested Classes
 
Java Inner Classes
Java Inner ClassesJava Inner Classes
Java Inner Classes
 
Inner Classes
Inner ClassesInner Classes
Inner Classes
 
Javasession8
Javasession8Javasession8
Javasession8
 
C# Access modifiers
C# Access modifiersC# Access modifiers
C# Access modifiers
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Introducing classes
Introducing classesIntroducing classes
Introducing classes
 
Oepnfiledialog
OepnfiledialogOepnfiledialog
Oepnfiledialog
 
Access modifiers
Access modifiersAccess modifiers
Access modifiers
 
Oops (inheritance&interface)
Oops (inheritance&interface)Oops (inheritance&interface)
Oops (inheritance&interface)
 
Index_2
Index_2Index_2
Index_2
 
Itpfldap aug2016
Itpfldap aug2016Itpfldap aug2016
Itpfldap aug2016
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Lo5
Lo5Lo5
Lo5
 
Java Access Specifier
Java Access SpecifierJava Access Specifier
Java Access Specifier
 

Viewers also liked

Strategies logistique -
Strategies logistique -Strategies logistique -
Strategies logistique -Logicités
 
第31回「こすぎの大学~武蔵小杉のライフプラン~」
第31回「こすぎの大学~武蔵小杉のライフプラン~」第31回「こすぎの大学~武蔵小杉のライフプラン~」
第31回「こすぎの大学~武蔵小杉のライフプラン~」克彦 岡本
 
Max ontdekt de stad
Max ontdekt de stadMax ontdekt de stad
Max ontdekt de stadnathaliekrol
 
Traditional british meals
Traditional british mealsTraditional british meals
Traditional british mealslepert32
 
Max ontdekt de stad.6
Max ontdekt de stad.6Max ontdekt de stad.6
Max ontdekt de stad.6nathaliekrol
 
Informe vice presidente joregre arreasa de trabajadores tercerizados lukiven...
Informe  vice presidente joregre arreasa de trabajadores tercerizados lukiven...Informe  vice presidente joregre arreasa de trabajadores tercerizados lukiven...
Informe vice presidente joregre arreasa de trabajadores tercerizados lukiven...HAROLDENRIQUE
 
מידעון אביב- פרויקט אפיק
מידעון אביב- פרויקט אפיקמידעון אביב- פרויקט אפיק
מידעון אביב- פרויקט אפיקNoa Greenstep
 
Iterasys :: Café com Qualidade - Testadores Precisam Saber Programar?
Iterasys ::  Café com Qualidade - Testadores Precisam Saber Programar?Iterasys ::  Café com Qualidade - Testadores Precisam Saber Programar?
Iterasys :: Café com Qualidade - Testadores Precisam Saber Programar?José Correia
 
Plain text presentation for slideshare
Plain text presentation for slidesharePlain text presentation for slideshare
Plain text presentation for slideshareNitish Bhardwaj
 
Datos mercadeo digital
Datos mercadeo digitalDatos mercadeo digital
Datos mercadeo digitalconny_quintero
 

Viewers also liked (19)

smse in india
smse in indiasmse in india
smse in india
 
Strategies logistique -
Strategies logistique -Strategies logistique -
Strategies logistique -
 
第31回「こすぎの大学~武蔵小杉のライフプラン~」
第31回「こすぎの大学~武蔵小杉のライフプラン~」第31回「こすぎの大学~武蔵小杉のライフプラン~」
第31回「こすぎの大学~武蔵小杉のライフプラン~」
 
Max ontdekt de stad
Max ontdekt de stadMax ontdekt de stad
Max ontdekt de stad
 
Tweets truman
Tweets trumanTweets truman
Tweets truman
 
Traditional british meals
Traditional british mealsTraditional british meals
Traditional british meals
 
Max ontdekt de stad.6
Max ontdekt de stad.6Max ontdekt de stad.6
Max ontdekt de stad.6
 
Informe vice presidente joregre arreasa de trabajadores tercerizados lukiven...
Informe  vice presidente joregre arreasa de trabajadores tercerizados lukiven...Informe  vice presidente joregre arreasa de trabajadores tercerizados lukiven...
Informe vice presidente joregre arreasa de trabajadores tercerizados lukiven...
 
Neymar
Neymar Neymar
Neymar
 
Aspek sosial
Aspek sosialAspek sosial
Aspek sosial
 
מידעון אביב- פרויקט אפיק
מידעון אביב- פרויקט אפיקמידעון אביב- פרויקט אפיק
מידעון אביב- פרויקט אפיק
 
Iterasys :: Café com Qualidade - Testadores Precisam Saber Programar?
Iterasys ::  Café com Qualidade - Testadores Precisam Saber Programar?Iterasys ::  Café com Qualidade - Testadores Precisam Saber Programar?
Iterasys :: Café com Qualidade - Testadores Precisam Saber Programar?
 
Event
EventEvent
Event
 
Awt
AwtAwt
Awt
 
Understanding Flyer
Understanding FlyerUnderstanding Flyer
Understanding Flyer
 
NMD BETA Jobs show
NMD BETA Jobs showNMD BETA Jobs show
NMD BETA Jobs show
 
Plain text presentation for slideshare
Plain text presentation for slidesharePlain text presentation for slideshare
Plain text presentation for slideshare
 
Datos mercadeo digital
Datos mercadeo digitalDatos mercadeo digital
Datos mercadeo digital
 
Perluasan kuasa
Perluasan kuasaPerluasan kuasa
Perluasan kuasa
 

Similar to Inner class (20)

A1771937735_21789_14_2018__16_ Nested Classes.ppt
A1771937735_21789_14_2018__16_ Nested Classes.pptA1771937735_21789_14_2018__16_ Nested Classes.ppt
A1771937735_21789_14_2018__16_ Nested Classes.ppt
 
Nested classes in java
Nested classes in javaNested classes in java
Nested classes in java
 
types of classes in java
types of classes in javatypes of classes in java
types of classes in java
 
Nested class in java
Nested class in javaNested class in java
Nested class in java
 
type of class in c#
type of class in c#type of class in c#
type of class in c#
 
Nested class
Nested classNested class
Nested class
 
Inner class
Inner classInner class
Inner class
 
Inner classes9 cm604.28
Inner classes9 cm604.28Inner classes9 cm604.28
Inner classes9 cm604.28
 
Object oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptxObject oriented programming CLASSES-AND-OBJECTS.pptx
Object oriented programming CLASSES-AND-OBJECTS.pptx
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
Lecture09.ppt
Lecture09.pptLecture09.ppt
Lecture09.ppt
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Unit 3
Unit 3Unit 3
Unit 3
 
C# structure
C# structureC# structure
C# structure
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Class
ClassClass
Class
 
Oops
OopsOops
Oops
 
OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)OOPS Characteristics (With Examples in PHP)
OOPS Characteristics (With Examples in PHP)
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 

More from Medivh2011

More from Medivh2011 (17)

北京圣思园深入Java虚拟机 class loader
北京圣思园深入Java虚拟机 class loader北京圣思园深入Java虚拟机 class loader
北京圣思园深入Java虚拟机 class loader
 
Unit test lesson 3
Unit test lesson 3Unit test lesson 3
Unit test lesson 3
 
Unit test lesson 1
Unit test lesson 1Unit test lesson 1
Unit test lesson 1
 
Unit test lesson 2
Unit test lesson 2Unit test lesson 2
Unit test lesson 2
 
Swing
SwingSwing
Swing
 
Reflection
ReflectionReflection
Reflection
 
Network
NetworkNetwork
Network
 
Multithread
MultithreadMultithread
Multithread
 
Jdk5
Jdk5Jdk5
Jdk5
 
Io 3
Io 3Io 3
Io 3
 
Io 2
Io 2Io 2
Io 2
 
Io 1
Io 1Io 1
Io 1
 
El
ElEl
El
 
Collection
CollectionCollection
Collection
 
Clone
CloneClone
Clone
 
Class loader
Class loaderClass loader
Class loader
 
Ant
AntAnt
Ant
 

Recently uploaded

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 

Inner class

  • 2. Group related classes and thus reduce namespace clutter defined at a scope smaller than a package An inner class can be defined inside another class, inside a method, and even as part of an expression There are four types of inner classes • static inner classes (also called nested classes) • member inner classes • local inner classes • anonymous inner classes
  • 3. The simplest form of inner class Can’t have the same name as the enclosing class Compiled into a completely separate .class file from the outer class Can access only static members and methods of the enclosing class, including private static members Create an instance of a static inner class out of enclosing class: • new outerclass.innerclass()
  • 4.  Defined in an enclosing class without using the static modifier  Like instance variables  Can access all members of the enclosing class  Create an instance within the enclosing class this.new Innerclass();  Create an instance out of the enclosing class (new Outerclass()).new Innerclass();  Access members of the enclosing class within inner classes Outerclass.this.member
  • 5. Defined within the scope of a method, even smaller blocks within methods The least used form of inner class Like local variables, can’t be declared public, protected, private and static Can only access final local variables
  • 6. Local inner classes which don’t have class names No key word class No key word extends and implements No constructors Implicitly extend a superclass or implement an interface