Cheap Web Hosting | Free Web Hosting | Dedicated Servers | Windows Hosting | Free Web Space | Trade Show Displays | GoDaddy Coupon Codes | FrontPage Hosting | Business Hosting
cheap web hosting
Search the Web

www.go4java.20m.com
 

 

A Place for Java Programmers!
 

 

In this table I have explained the relation between different modifiers and different types of inner classes like which modifier can be used with inner classes, which methods and variables are accessible in inner classes, which methods and variables are allowed to be declared in inner classes, which type of inheritance is allowed with inner classes:

 

  MODIFIERS  WHICH CAN BE USED WITH INNER CLASSES

Modifier

Non-Static Inner Class

Static Inner Class

Local Class  

Anonymous Inner Class

public

Yes

Yes

No

No

protected Yes

Yes

No

No

No-modifier

Yes

Yes

Yes

Yes

private Yes Yes No No
final Yes Yes Yes No
abstract Yes Yes Yes No
static Yes Already No No

ACCESSIBILITY TO VARIABLES AND METHODS OF OUTER CLASS

outer's non-static Yes No Yes Yes
outer's static Yes Yes Yes Yes
outer's private Yes Yes(static) Yes Yes
outer's final Yes Yes(static) Yes Yes

encl. method's  

N/A N/A Yes(final) Yes(final)

DECLARATION ALLOWED FOR VARIABLES AND METHODS

static No Yes No No
non-static Yes Yes Yes Yes

INHERITANCE ALLOWED WITH CLASSES AND INTERFACES

with  class Yes Yes Yes Yes
with interface Yes Yes Yes Yes (one)