Your SlideShare is downloading. ×
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Nested and Enum in Java
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Nested and Enum in Java

1,303

Published on

Understanding nested type and inner class

Understanding nested type and inner class

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,303
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Prepared Using Nested Type For Semester – III [MCA] August 2012 Prepared by Prof. Ashish Bhatia ast.bhatia@gmail.com ashish@asbspace.in www.asbspace.in1 Prepared By: Prof. Ashish Bhatia
  • 2. Note ● This ppt is for teaching purpose only. ● The ppt may contain some material from books/api documentation/internet. ● No intention of breaking any rights or what so ever.2 Prepared By: Prof. Ashish Bhatia
  • 3. Nested Classes ● The class define inside another class are known as Nested Class. ● Top Level Nested Class ● Inner class is static ● Inner Class ● Local Class ● Anonymous Class3 Prepared By: Prof. Ashish Bhatia
  • 4. Why we need nested class? ● Logical Grouping of class ● Helper classes ● Increase encapuslation ●4 Prepared By: Prof. Ashish Bhatia
  • 5. Top Level Nested Class ● Static member class is also known as top level nested class. ● Member class and enclosing class shares trust replationship in that they can access each other memebers, including private members.5 Prepared By: Prof. Ashish Bhatia
  • 6. 6 Prepared By: Prof. Ashish Bhatia
  • 7. Inner Classes ● Non-static member classes. ● Relationship : ● We cannot have an instance of innerclass without having instance of the outer class. ● Used to represent one to many relationship. ● Eg : Account Class [Outer]and Transaction class[Inner] ● We cannot have transaction without Account ● Inner class cannot have static members.7 Prepared By: Prof. Ashish Bhatia
  • 8. 8 Prepared By: Prof. Ashish Bhatia
  • 9. Local Class ● Class inside a method, constructor or intializer block. ● This class donot have access specifier and cannot be dcelared static / non-static.9 Prepared By: Prof. Ashish Bhatia
  • 10. 10 Prepared By: Prof. Ashish Bhatia
  • 11. Anonymous Class ● Do not have name. ● Defined and created at same place. ● Become part of expression. ● Single inheritance type either extend or implement ● Always non-abstract.11 Prepared By: Prof. Ashish Bhatia
  • 12. enum Type ● Java 5 onwards. ● Cannot have super class but can implement interface. ● Number of instances are fixed. ● ; required after declaration. ● Sub class of Enum ● Instances have name and ordinal value.12 Prepared By: Prof. Ashish Bhatia
  • 13. enum Type ● Each instance are static and final. ● Ordinal Value starts from 0 ● To access Month.January ● Enum type are comparable [ ordinal] ● Values and Valuesof ● public static Month[] values() ● public static Month valueOf(String n)13 Prepared By: Prof. Ashish Bhatia

×